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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.