- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;