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.;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 1412 views
  • 0 likes
  • 2 in conversation