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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 858 views
  • 0 likes
  • 2 in conversation