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

Hello , 

I have a data set of multiple dates , and for each data a maturity 

the maturities in the data are coded in numbers , for example  2 means 52 weaks , 3 means 2 years , 4 means 5 years ....

I want to recode this variable so that for each number I get the text instead. 

Thank you in advance

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Use a format:

http://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/viewer.htm#n1c16dxnndwfzyn14o1kb...

That is exactly what they are for.

proc format;
  value tmp
    2="52 weeks"
    3="2 years";
run;

data want;
  set have;
  format var1 var2 tmp.;
run;

View solution in original post

6 REPLIES 6
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Use a format:

http://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/viewer.htm#n1c16dxnndwfzyn14o1kb...

That is exactly what they are for.

proc format;
  value tmp
    2="52 weeks"
    3="2 years";
run;

data want;
  set have;
  format var1 var2 tmp.;
run;
LoPez_Diaz
Obsidian | Level 7

Hello and thank you for your fast reply 

I'm new to sas , and i'm discovering this functions.

so when I used your code , I got the following error : 

 

28 6="2Y";
_
180
ERROR 180-322: Statement is not valid or it is used out of proper order.

 

Any clue ? 
Thank you 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

The error tells you the issue, that statement is used incorrectly.  So its likely something before that has gone wrong.  As you haven't shown the full log however there is no way I can tell.  Refer to the code I presented and see what is different with your code, and then post the log here, all relevant log output.

LoPez_Diaz
Obsidian | Level 7

Thank you all for your help .


Have a great day.

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
  • 6 replies
  • 1208 views
  • 0 likes
  • 3 in conversation