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

I have a time series data set in excel, 60 rows, that I uploaded in SAS On Demand Studio.  I need to add a column for months containing  Jan through Dec.  Since 60 months, it means 5 years which means each month has to be written  5 times.  For example Jan at  1st row, then at 13th row, etc...and on.  I could go back to my excel file and do it and then upload into SAS the newly modified file.  I wonder if I could do this within SAS without deleting, modifying and uploading>

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

It's almost certain that you would be better off constructing MONTH as a numeric variable taking on values 1 through 12.  That's fairly easy:

 

data want;

set have;

month + 1;

if month = 13 then month = 1;

run;

 

If you want to print MONTH, and see it in a different form, you can always create a format.  

 

proc format;

value mm 1='Jan' 2='Feb' 3='Mar' 4='Apr' 5='May' 6='Jun' 7='Jul' 8='Aug' 9='Sept' 10='Oct' 11='Nov' 12='Dec';

run;

 

Then when printing, apply the format:

 

format month mm.;

View solution in original post

1 REPLY 1
Astounding
PROC Star

It's almost certain that you would be better off constructing MONTH as a numeric variable taking on values 1 through 12.  That's fairly easy:

 

data want;

set have;

month + 1;

if month = 13 then month = 1;

run;

 

If you want to print MONTH, and see it in a different form, you can always create a format.  

 

proc format;

value mm 1='Jan' 2='Feb' 3='Mar' 4='Apr' 5='May' 6='Jun' 7='Jul' 8='Aug' 9='Sept' 10='Oct' 11='Nov' 12='Dec';

run;

 

Then when printing, apply the format:

 

format month mm.;

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!
What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 1460 views
  • 0 likes
  • 2 in conversation