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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

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.

View solution in original post

4 REPLIES 4
Haikuo
Onyx | Level 15

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

Danglytics
Calcite | Level 5

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.

Haikuo
Onyx | Level 15

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.

Danglytics
Calcite | Level 5

Thank you very much.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 4 replies
  • 1206 views
  • 0 likes
  • 2 in conversation