BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Idi
Obsidian | Level 7 Idi
Obsidian | Level 7
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
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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 value L'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

5 REPLIES 5
PaigeMiller
Diamond | Level 26

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 value L'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
PaigeMiller
Diamond | Level 26

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

--
Paige Miller
Idi
Obsidian | Level 7 Idi
Obsidian | Level 7
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
PaigeMiller
Diamond | Level 26

Then you will need different formats for each variable.

--
Paige Miller
Idi
Obsidian | Level 7 Idi
Obsidian | Level 7
Thank you so much

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 443 views
  • 1 like
  • 2 in conversation