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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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