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?
proc format;
value $product 'Orange' = 'org1-2';
run;
should be
proc format;
value $product 'org1-2' = 'Orange';
run;
proc format;
value $product 'Orange' = 'org1-2';
run;
should be
proc format;
value $product 'org1-2' = 'Orange';
run;
It worked thanks @PaigeMiller , I was close just had to inverse the order. Thanks again.
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.
proc format;
value $product 'org1-2' = 'Orange'
'ban3-3' = 'banana';
run;
@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.
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.
No worries I got it.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.