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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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