Hi,
I'm not sure how to classify an ID to the month end date when I have a date variable for them.
for example i'd like my data set to look like: where i have ID and Date and need to create FILE PERIOD
ID Date FILE_PERIOD
1 01Jan2012 31Jan2012
2 05Feb2012 29Feb2012
etc..
thank you for your help.
Then try this:
data want ;
set have;
_n_=intnx('month',date,0,'e');
FILE_PERIOD=cats(put(_n_, yymon7.),day(_n_));
run;
Haikuo
Edit: just updated.
Try this one:
data have;
input id $ date :date9.;
format date date9.;
cards;
1 01Jan2012
2 05Feb2012
;
data want;
set have;
FILE_PERIOD=intnx('month',date,0,'e');
format FILE_PERIOD date9.;
run;
Regards,
Haikuo
Great thank you that worked.
Is there a way to get FILE_PERIOD into a character format with the following format structure?
for example the code above will give me 31Jan2012, but i'd like FILE_PERIOD to be 2012Jan31 so that it is consistent with my other formats.
Then try this:
data want ;
set have;
_n_=intnx('month',date,0,'e');
FILE_PERIOD=cats(put(_n_, yymon7.),day(_n_));
run;
Haikuo
Edit: just updated.
Thank you very much.
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.
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.