Hi,
Can someone tell me how to create a new variable named 'End_of_study' in the format 31/12/2012, which has to be the same for all entries/rows.
Regards,
This question, and a lot more, can be learned in the free online SAS Programming course.
This question, and a lot more, can be learned in the free online SAS Programming course.
data want;
set have;
retain End_of_Study '31Dec2012'd;
format End_of_Study ddmmyys10.;
run;
Data want;
set have;
End_of_study = '31DEC2012'd;
format End_of_study ddmmyy10.;
run;
Note that SAS only accepts one way to assign a date literal if you want to use it as a date value allowing use of the various date functions and formats.
Otherwise use a character value any way you want it.
Thanks all of you for the support.
I've come accross another question. I've imported a date variable from excell; but the format for the date variable is in text and perhaps this is why the missing values are not marked in "." BUT are just blank cells in SAS Viewtable.
I appreciate if someone can advise on how to format the text to sas date value (such as 01/12/2011)
Cheers,
Tawfiq
What do,the date values look like now?
It would be something like:
new_var = input (date_var, current_format.);
formate new_var ddmmyy10.;
Your code:
LRec_date=input (Last_date, $10.);
format LRec_date ddmmyy10.;
Creates a text variable, that is what input using the informat $10. does.
Try
LRec_date=input (Last_date, ddmmyy10.);
format LRec_date ddmmyy10.;
Hi,
It works. Thanks for the help!
Just a heads up to the free SAS training available that has been alluded to:
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.