BookmarkSubscribeRSS Feed
Alankar
Fluorite | Level 6
Hi All,
I've assigned below macro.
%let date = 20090723(yymmddn8.)
but the question is the i want to change it in to Date ormat.
using this macro i need another variable "newdate" is in any type of Date format. like date9., mmddyy...........

Thanks in Advance
Alankar
3 REPLIES 3
Doc_Duke
Rhodochrosite | Level 12
I think what you want is

newdate=INPUT(&date, yymmdd8.);

(Assuming yout %LET is actually

%LET date = 20090723;
)
deleted_user
Not applicable
I assume you are asking how to set a dataset variable from the value of a macro variable. In this case you could use the INPUT function.

newdate=input("&date",mmddyy.);

If you want to control how this new numeric variable is displayed then you can attach a format to it.

If you want to store the value into a character variable then you could use the PUT function.

newdatef = put(newdate,date9.);
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Your final use of this data-string is unclear - so does the data need to be a SAS date variable with an internal representation (days since Jan 1, 1960) or are you expecting a formatted value (1/1/2009)?

Regardless, if you want to use SAS macro language only, you will need to look into using %SYSFUNC and at least the INPUT function to convert the character-representation to a SAS DATE value, and then if you also want to re-format the string to display a formatted DATE, you will again use %SYSFUNC and the PUTN function with the appropriate SAS format.

Suggest searching the SAS support http://support.sas.com/ website using keywords from the information provided in this post reply -- you will find both SAS-hosted documentation and also supplemental technical/conference papers on this topic.

Scott Barry
SBBWorks, Inc.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 1534 views
  • 0 likes
  • 4 in conversation