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

I have something like

data one;

merge dataset1 dataset2;

.................

if var=1 then var='large';

else var='small';

run;

Now, the variable var is extracted from datasets 1 and 2 with a numeric format;however 'large' and 'small' are character and this generates errors.

How can I transform from numeric to character within the data step as created above?

I tried adding "format var $6.;" but this did not solve the problem.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

proc format ;

value size 1='large' other='small';

run;

proc sgplot;

by var;

format var size. ;

run;

View solution in original post

3 REPLIES 3
art297
Opal | Level 21

Do you really want to assign new values?  Or, on the other hand, do you simply want the character values to appear in lists, reports and or analyses?  If it is the latter, you can create and assign a format.

Bogdan
Calcite | Level 5

I want to use the variable in

proc sgplot;

by var;

So yes, I do no necessarily need to assign new values, but I need more info.

Tom
Super User Tom
Super User

proc format ;

value size 1='large' other='small';

run;

proc sgplot;

by var;

format var size. ;

run;

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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