SAS Programming

DATA Step, Macro, Functions and more
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-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

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