Hi.
I have the following similar variables.
site_p1_1
site_p1_2
site_p1_3
site_p2_1
site_p2_2
site_p2_3
.
.
.
site_p50_1
site_p50_2
site_p50_3
All variables have the same choices, 1 = good, 2 = better and 3 = best.
I want to use Proc format. What is the most efficient way to code it?
Thank you for your help!
@yoyong wrote:
Hi.
I have the following similar variables.
site_p1_1
site_p1_2
site_p1_3
site_p2_1
site_p2_2
site_p2_3
.
.
.
site_p50_1
site_p50_2
site_p50_3
All variables have the same choices, 1 = good, 2 = better and 3 = best.
I want to use Proc format. What is the most efficient way to code it?
Thank you for your help!
You use proc format to create a value format (numeric or character, depending on the type of the variables you want to use it on).
Then you assign it using the wildcard colon:
format site_p: myfmt.;
data sss;
input a_1 a_2 a_3 a_b1 a_b2 a_b3;
cards;
1 2 3 3 2 1
2 1 3 3 2 1
1 2 3 3 3 3
run;
proc format;
value likert 1 = 'good'
2 = 'better'
3 = 'best';
run;
proc print data=sss;
format a_: likert.;
run;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.