BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
samface
Calcite | Level 5

Hello,

 

I need help renaming values of a string variable and perform a proc freq procedure. The column looks like this:

 

Column name: Product

Column values: (org1-2, ban3-3)

 

I would like to change the format of my column values to:

org1-2 = orange

ban3-3 = banana

 

I used the following code:

 

proc format;

value $product 'Orange' = 'org1-2';

run; 

proc freq data=work.food;

tables product;

format product $product.;

run; 

 

I ran the code, the values didn't change to the format I specified in my code. Any help?

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

proc format;

value $product 'Orange' = 'org1-2';

run; 

 

should be

 

proc format;
    value $product 'org1-2' = 'Orange';
run; 
--
Paige Miller

View solution in original post

7 REPLIES 7
PaigeMiller
Diamond | Level 26

proc format;

value $product 'Orange' = 'org1-2';

run; 

 

should be

 

proc format;
    value $product 'org1-2' = 'Orange';
run; 
--
Paige Miller
samface
Calcite | Level 5

It worked thanks @PaigeMiller , I was close just had to inverse the order. Thanks again. 

samface
Calcite | Level 5

@PaigeMiller 

 

Another question, when I ran the same code for the other value, the additional aren't formatted. Do you know why?

 

proc format;
    value $product 'org1-2' = 'Orange'
'ban3-3 = 'banana'; run;

I used the above code.  

samface
Calcite | Level 5

proc format;

value $product 'org1-2' = 'Orange'

                        'ban3-3' = 'banana';

run;

 

 

 

 

PaigeMiller
Diamond | Level 26

@samface wrote:

 

Another question, when I ran the same code for the other value, the additional aren't formatted. Do you know why?

 

 I don't know what this means.

--
Paige Miller
samface
Calcite | Level 5

OK sorry for the typo.

 

I used the code below to format additional value whitin my column but nothing has changed. 

 

proc format;

value $product 'org2-2' = 'orange'

                         'ban3-3' = 'banana';

run; 

 

When I ran it, the formatting only works for 'orange' and not 'banana'. Am I doing something wrong? or do I need to create a new format for each additional value in my product colum?

 

Thanks.

samface
Calcite | Level 5

No worries I got it. 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

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
  • 7 replies
  • 1634 views
  • 0 likes
  • 2 in conversation