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. 

Ready to join fellow brilliant minds for the SAS Hackathon?

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