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

Dear All,

I would like to write a SAS program to get the current date and determine number of days in the month prior to current month.

Find difference in days, months, and years between. Is it possible using SAS ?

Thanks a lot for help.

Regards,

S Ravuri.

1 ACCEPTED SOLUTION

Accepted Solutions
sambasiva_ravuri_tcs_com
Calcite | Level 5

Keith,

Code worked Well. Thanks a lot and appreciate for your great help.

Regards,

S Ravuri.

View solution in original post

4 REPLIES 4
Keith
Obsidian | Level 7

This looks a very similar question to one I answered earlier today.  Check out my reply and the link I included, they should give you some ideas on how to do this.

http://communities.sas.com/message/119624#119624

sambasiva_ravuri_tcs_com
Calcite | Level 5

Thanks Keith for the reply.

Am getting the values for difference in days, months, and years in between.

Can you please help me how can we get the no.of days for prior month to the current month.

Thanks a lot in advance for help.

Regards,

S Ravuri.

Keith
Obsidian | Level 7

Just use the INTNX function as below.  This will subtract the 1st of the previous month from the 1st of the current month.

data num_days;

a=today();

prev_month=intnx('month',a,0)-intnx('month',a,-1);

run;

sambasiva_ravuri_tcs_com
Calcite | Level 5

Keith,

Code worked Well. Thanks a lot and appreciate for your great help.

Regards,

S Ravuri.

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