BookmarkSubscribeRSS Feed
yoyong
Obsidian | Level 7

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!

 

2 REPLIES 2
Kurt_Bremser
Super User

@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.;
Sathish_jammy
Lapis Lazuli | Level 10
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;

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 25. 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
  • 2 replies
  • 736 views
  • 2 likes
  • 3 in conversation