Help using Base SAS procedures

assign "Yes" "No" to variables.

Reply
Frequent Contributor
Posts: 128

assign "Yes" "No" to variables.

I have several binary variables (1, 2). I tried to label them all to "Yes, No".
Is there any easier way to do this? I remember I used "format" statement before, but cannot recall how i did that. Don't want to use "if then" statement, too many variables.
Any help? thanks!
Super Contributor
Super Contributor
Posts: 365

Re: assign "Yes" "No" to variables.

Hello Ken_oy,

This is a solution:
[pre]
data a;
bin=1; output;
bin=2; output;
bin=.; output;
run;
proc format;
value bin
1= "Yes"
2= "No "
other="Unk";
run;
proc print data=a;
format bin bin.;
run;
[/pre]
Sincerely,
SPR
Super User
Posts: 10,526

Re: assign "Yes" "No" to variables.

Hint: If you want to have the format available all the time put it in a permanent library by adding the LIBRARY= option to the PROC step. Reference e that library in the format search path using the FMTSEARCH system option or other tool.
Ask a Question
Discussion stats
  • 2 replies
  • 234 views
  • 0 likes
  • 3 in conversation