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

from a given date for ex. 1st nov 2013

1. assign the date in yyyy_mm format to a macro variable

2.Assign the date in MMM_YY foramt to a macro variable

1 ACCEPTED SOLUTION

Accepted Solutions
Eshan
Calcite | Level 5

Here it is.

data temp;

dt = today();

call symput('dt1', catx('_', year(dt), put(month(dt),2.)));

call symput('dt2', catx('_', substr(put(dt,date9.),3,3), substr(put(dt,date9.),8,2)));

run;

%put &dt1= &dt2=;


View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

Answer to #1: %let macrovar=2013_11;

Answer to #2: should be obvious from answer to #1

--
Paige Miller
Eshan
Calcite | Level 5

Here it is.

data temp;

dt = today();

call symput('dt1', catx('_', year(dt), put(month(dt),2.)));

call symput('dt2', catx('_', substr(put(dt,date9.),3,3), substr(put(dt,date9.),8,2)));

run;

%put &dt1= &dt2=;


sahaji
Calcite | Level 5

Thanks for your reply,it is helpful for me, giving correct result

data_null__
Jade | Level 19

Maybe this is what you mean.  Your question is somewhat vague.

18         %let given=%sysevalf('1nov2013'd);
19        
20         %let a = %sysfunc(putn(&given,yymon));
21         %let b = %sysfunc(putn(&given,monyy));
22         %put NOTE: &=a &=b;
NOTE: A=2013NOV B=NOV13

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 888 views
  • 0 likes
  • 4 in conversation