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

Hi Everyone,

I want to create a macro variable that take the value of today date in the form yyyymmdd.

I can do it with my code below but I have to start with a dataset "mydata".

I thought that there should be a way to use _NULL_ data but I cant work it out.

Can you help me?

Thank you,

HC

 

*SOLUTION --------------------------------

data _NULL_;
format today yymmdd8.;
today=date(); 
ymd=year(today)*10000+month(today)*100+day(today);

   call symputx('next_month',put(ymd,10.));

run;

%put &next_month;

 


data TEMP; 		set Mydata;
format today yymmdd8.;
today=date(); 
ymd=year(today)*10000+month(today)*100+day(today);run;

	proc sql;
	select Max(ymd) into:todaydate
	from  TEMP;quit;

	%put &todaydate;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

I don't really understand what your question is.

You do not need to have an input dataset to run a data step.

data _null_;
   x=today();
   next_month=intnx('month',x,1,'b');
   call symputx('next_month',put(next_month,yymmddn8.));
run;

View solution in original post

5 REPLIES 5
Reeza
Super User

Look up %SYSFUNC and note the two parameters.

 

%let today = %sysfunc(today(), yymmdd8.);

%put &today.;
hhchenfx
Rhodochrosite | Level 12

Thank you for the suggestion.

 

I am more concern with manipulating the value a bit before passing it to macro variable.

 

HC

SuryaKiran
Meteorite | Level 14

hi,

 

Check out "CALL SYMPUT" which can pass the value to a macro variable with DATA _NULL_

Thanks,
Suryakiran
Tom
Super User Tom
Super User

I don't really understand what your question is.

You do not need to have an input dataset to run a data step.

data _null_;
   x=today();
   next_month=intnx('month',x,1,'b');
   call symputx('next_month',put(next_month,yymmddn8.));
run;
hhchenfx
Rhodochrosite | Level 12
Thanks a lot.
HC

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1459 views
  • 0 likes
  • 4 in conversation