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

Hey folks,

I know one day the light bulb will go off, but I still struggle with SAS dates.  I want a 2 digit month variable called 'emo' that I can pass to other data steps.  It resolves to '2' and I want '02'.  Here's my code:  Mucho thanks!

data _null_;
sdate = '01feb2015'd;
edate = '28feb2015'd;

emo = month(edate);
eyr = year(edate);

call symput ('sdate', "'"||trim(left(put(sdate, date9.)))||"'");
call symput ('edate', "'"||trim(left(put(edate, date9.)))||"'");
call symput ('emo',emo);
call symput ('eyr',eyr);
put emo = 2.;
fim_tu_wo = cats(of eyr,emo);
call symput ('fim_tu_wo', trim(left(put(fim_tu_wo,$7.))));

put _all_;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

If your emo variable is numeric then use Z2. format;

But if you are looking to create 201502

try call symput (fim_tu_wo, put(edate,yymmn6.));

View solution in original post

2 REPLIES 2
ballardw
Super User

If your emo variable is numeric then use Z2. format;

But if you are looking to create 201502

try call symput (fim_tu_wo, put(edate,yymmn6.));

BU2B
Calcite | Level 5

Thank you sir!

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