Replacing values with text but got just 2 characters (2024)

☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.

<!#-- DETERMINE THREAD OR REPLY --> <!#-- GET THE MESSAGE ID AND DATA, EITHER WAY -->

<!#-- ASSIGN MESSAGE AND AUTHOR QUERIES APPROPRIATELY -->

Replacing values with text but got just 2 characters (2) Idi

Obsidian | Level 7

Go to Solution

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

Replacing values with text but got just 2 characters

<!#-- DETERMINE THREAD OR REPLY -->

Posted Thursday (279 views)

Hello ,

I have data with multiples columns : A -- Q
Inside the column i have 3 valies : N/A , Yes , No
I want to replace Yes with a text like :
If A = Yes then A = "L'utilisateur marche bien "
But i got only : L'u

And i want to replace all the N/A and No with blank : " " just blank.

Can you help please ?

Thanks so much

0Likes

Reply

1 ACCEPTED SOLUTION


Accepted Solutions

<!#-- DETERMINE THREAD OR REPLY --> <!#-- GET THE MESSAGE ID AND DATA, EITHER WAY -->

<!#-- ASSIGN MESSAGE AND AUTHOR QUERIES APPROPRIATELY -->

Replacing values with text but got just 2 characters (4) PaigeMiller

Diamond | Level 26

<!#-- DETERMINE THREAD OR REPLY -->

Posted Thursday (254 views) | In reply to Idi

Easier would be to use custom format

proc format; value $fmt 'Yes'="L'utilisateur marche bien" 'No','N/A'=' ';run;data want; set have; format a--q $fmt.;run;

The reason your code won't work without modification is that A--Q has a length of 3 characters, this doesn't change when assigning the valueL'utilisateur marche bien, you only get the first 3 characters. You would need use a LENGTH statement to change this.

length a--q $ 25;

because the text you want is 25 characters. But really, use the easier approach which is PROC FORMAT above.

--
Paige Miller

View solution in original post

  • Tags:
  • Thank you so much its works very well. Just another question : if the string value IS différent for B C ... Q . I Have différent text value for each columns. For A= "l'utilisateur marche bien". I have another text for B etc -- Q

1Like

Reply

5 REPLIES 5

<!#-- DETERMINE THREAD OR REPLY --> <!#-- GET THE MESSAGE ID AND DATA, EITHER WAY -->

<!#-- ASSIGN MESSAGE AND AUTHOR QUERIES APPROPRIATELY -->

Replacing values with text but got just 2 characters (6) PaigeMiller

Diamond | Level 26

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

Re: Replacing values with text but got just 2 characters

<!#-- DETERMINE THREAD OR REPLY -->

Posted Thursday (255 views) | In reply to Idi

Easier would be to use custom format

proc format; value $fmt 'Yes'="L'utilisateur marche bien" 'No','N/A'=' ';run;data want; set have; format a--q $fmt.;run;

The reason your code won't work without modification is that A--Q has a length of 3 characters, this doesn't change when assigning the valueL'utilisateur marche bien, you only get the first 3 characters. You would need use a LENGTH statement to change this.

length a--q $ 25;

because the text you want is 25 characters. But really, use the easier approach which is PROC FORMAT above.

--
Paige Miller

  • Tags:
  • Thank you so much its works very well. Just another question : if the string value IS différent for B C ... Q . I Have différent text value for each columns. For A= "l'utilisateur marche bien". I have another text for B etc -- Q

1Like

Reply

<!#-- DETERMINE THREAD OR REPLY --> <!#-- GET THE MESSAGE ID AND DATA, EITHER WAY -->

<!#-- ASSIGN MESSAGE AND AUTHOR QUERIES APPROPRIATELY -->

Replacing values with text but got just 2 characters (8) PaigeMiller

Diamond | Level 26

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

Re: Replacing values with text but got just 2 characters

<!#-- DETERMINE THREAD OR REPLY -->

Posted Thursday (236 views) | In reply to PaigeMiller

@Idi Please don't write followup questions in the field for tags. Please write your followup question by clicking on "Reply".

--
Paige Miller

0Likes

Reply

<!#-- DETERMINE THREAD OR REPLY --> <!#-- GET THE MESSAGE ID AND DATA, EITHER WAY -->

<!#-- ASSIGN MESSAGE AND AUTHOR QUERIES APPROPRIATELY -->

Replacing values with text but got just 2 characters (10) Idi

Obsidian | Level 7

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

Re: Replacing values with text but got just 2 characters

<!#-- DETERMINE THREAD OR REPLY -->

Posted Thursday (213 views) | In reply to PaigeMiller

Thank you so much its works very well. Just another question : if the string value IS différent for B C ... Q . I Have différent text value for each columns. For A= "l'utilisateur marche bien". I have another text for B etc -- Q

0Likes

Reply

<!#-- DETERMINE THREAD OR REPLY --> <!#-- GET THE MESSAGE ID AND DATA, EITHER WAY -->

<!#-- ASSIGN MESSAGE AND AUTHOR QUERIES APPROPRIATELY -->

Replacing values with text but got just 2 characters (12) PaigeMiller

Diamond | Level 26

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

Re: Replacing values with text but got just 2 characters

<!#-- DETERMINE THREAD OR REPLY -->

Posted Thursday (204 views) | In reply to Idi

Then you will need different formats for each variable.

--
Paige Miller

0Likes

Reply

<!#-- DETERMINE THREAD OR REPLY --> <!#-- GET THE MESSAGE ID AND DATA, EITHER WAY -->

<!#-- ASSIGN MESSAGE AND AUTHOR QUERIES APPROPRIATELY -->

Replacing values with text but got just 2 characters (14) Idi

Obsidian | Level 7

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

Re: Replacing values with text but got just 2 characters

<!#-- DETERMINE THREAD OR REPLY -->

Posted Thursday (221 views) | In reply to PaigeMiller

Thank you so much

0Likes

Reply

Replacing values with text but got just 2 characters (2024)

FAQs

How to replace multiple different characters in a string in SQL? ›

Replace Multiple Characters in MySQL
  1. REPLACE(text, search_string, replace_string)
  2. SELECT REPLACE('MySQL', 'M', 'W');
  3. SELECT REPLACE(REPLACE('MySQL', 'M', 'W'), 'S', 'Z');
Jan 4, 2024

How to replace one character in a string with another character? ›

Replacing a Character in a String using replace() method

In Python, strings are immutable, which means that once a string is created, it cannot be modified. However, you can create a new string by replacing certain characters in the original string. One way to do this is by using the replace() method.

How do you replace the first two characters of a string in Python? ›

Use the replace() method to replace substrings. Specify the old string old for the first argument and the new string new for the second argument. You can remove old by specifying new as the empty string '' .

How to replace only one character in string in Python? ›

Using 'str.

replace(), we can replace a specific character. If we want to remove that specific character, we can replace that character with an empty string. The str. replace() method will replace all occurrences of the specific character mentioned.

How do you swap two characters in a string? ›

Approach 3: Using a list comprehension
  1. # Input string.
  2. string = "hello world"
  3. # Swap characters at index 2 and index 6.
  4. char_list = [string[i] if i not in (2, 6) else string[6 if i == 2 else 2] for i in range(len(string))]
  5. # Convert list back to string.
  6. new_string = "". join(char_list)
  7. # Output new string.
  8. print(new_string)

How to use REGEXP_REPLACE in SQL? ›

If you call REGEXP_REPLACE and specify g in the parameters argument, the function performs a search and replace of all occurrences of a regular expression pattern with a replacement string. REGEXP_REPLACE supports the extended and advanced regular expression formats.

How to replace first two characters of string in Java? ›

The . replaceFirst() method replaces the first matching substring in a string with the specified replacement string.

How do you get the first two characters of a string? ›

To get the first two characters of a string in JavaScript, call the slice() method on the string, passing 0 and 2 as the first and second arguments respectively. For example, str. slice(0, 2) returns a new string containing the first two characters of str .

How do you swap two characters in a string in Python? ›

Program to swap string characters pairwise in Python
  1. s := make a list from the characters of s.
  2. for i in range 0 to size of s - 1, increase by 2, do. swap s[i], s[i+1] with s[i+1], s[i]
  3. join characters from s to make whole string and return.
Oct 12, 2021

How to replace values in Python? ›

  1. You can replace specific values in a DataFrame using the replace() method. ...
  2. The replace() method in pandas is used to replace a value with another value. ...
  3. To replace string values, you use the same replace() method.
Jul 11, 2024

How to replace text in Python? ›

How to replace a string expression in Python? You can use the replace() method to replace a substring with another substring in a string. original_string = "Hello, world!" print(new_string) # Output: Hello, Python!

How to replace elements in a string in Python? ›

Replace a Character in a String Using Replace() Method

The replace() method replaces occurrences of a specified character with another character in a string. Replace() method is the most straightforward approach for string manipulation.

How do you replace some characters in a string in SQL? ›

You can use the REPLACE function to replace part of a string in a single record or multiple records. This SQL function takes three arguments: the string you want to replace, the string you want to replace it with, and the string you want to search in.

How to replace special characters from string in SQL? ›

You could use TRANSLATE function (SQL Server 2017 14. x and later) first to convert all the special characters into same character say '-'. And then use REPLACE function. Note: The argument 12 equals the length of the special characters you are looking for.

How to remove two characters from a string in SQL? ›

The TRIM() function removes the space character OR other specified characters from the start or end of a string. By default, the TRIM() function removes leading and trailing spaces from a string. Note: Also look at the LTRIM() and RTRIM() functions.

How to split string from special characters in SQL? ›

The STRING_SPLIT(string, separator) function in SQL Server splits the string in the first argument by the separator in the second argument. To split a sentence into words, specify the sentence as the first argument of the STRING_SPLIT() function and the space ( ' ' ) as the second argument.

References

Top Articles
✨ Grip 20" Mega Tent Stake (2 pack) - Essential for Camping, Hiking, Gardening, Landscaping - Tents, Tarps, Canopies, Trees, Bushes — 🛍️ The Retail Market
The Web | Project Gutenberg
Extranet Landing Page Delta
Rick Steves Forum
This Modern World Daily Kos
The Phenomenon of the Breckie Hill Shower Video Understanding Its Impact and Implications - Business Scoop
Csl Plasma Birthday Bonus
Craiglist Tulsa Ok
Generation Zero beginner’s guide: six indispensable tips to help you survive the robot revolution
Body Rub Phoenix
Localhotguy
Metalico Sharon Pa
Myjohnshopkins Mychart
Shoulder Ride Deviantart
10 Teacher Tips to Encourage Self-Awareness in Teens | EVERFI
Leaf Blower and Vacuum Vacuum Hoses
Google Flights Msp To Fort Myers
Food King El Paso Ads
Ratchet And Clank Tools Of Destruction Rpcs3 Freeze
Director, Regional People
Wharton Funeral Home Wharton Tx
Gina's Pizza Port Charlotte Fl
Hahs Sentral
Dash Ag Grid
Wisconsin Volleyball Team Full Leaks
Review: 'Letters From Iwo Jima' a masterpiece - CNN.com
Vioc Credit Card Charge
Alloyed Trident Spear
Craigs List Plattsburgh Ny
Aldine Isd Pay Scale 23-24
Moss Adams Client Portal
Runescape Abyssal Beast
Ringcentral Background
Terraria Water Gun
Raileydiesel
Walb Game Forecast
Air Quality Index Endicott Ny
Lesley Ann Downey Transcript
Spacebar Counter - Space Bar Clicker Test
10000 Divided By 5
O'reilly's Eastman Georgia
General Kearny Inn Motel & Event Center
Avalon Hope Joi
Fandafia
Alles, was ihr über Saison 03 von Call of Duty: Warzone 2.0 und Call of Duty: Modern Warfare II wissen müsst
Pinellas Fire Active Calls
Neo Geo Bios Raspberry Pi 3
Swoop Amazon S3
palm springs free stuff - craigslist
304-733-7788
Nfl Spotrac Transactions
Vimeo Downloader - Download Vimeo Videos Online - VEED.IO
Latest Posts
Article information

Author: Rubie Ullrich

Last Updated:

Views: 5634

Rating: 4.1 / 5 (52 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Rubie Ullrich

Birthday: 1998-02-02

Address: 743 Stoltenberg Center, Genovevaville, NJ 59925-3119

Phone: +2202978377583

Job: Administration Engineer

Hobby: Surfing, Sailing, Listening to music, Web surfing, Kitesurfing, Geocaching, Backpacking

Introduction: My name is Rubie Ullrich, I am a enthusiastic, perfect, tender, vivacious, talented, famous, delightful person who loves writing and wants to share my knowledge and understanding with you.