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-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!

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.

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