data date;
set sashelp.date;
DateZ = INPUT(PUT(19000000+DATEF,Z8.),YYMMDD8.);
CALL SYMPUT('DATE_P',DATE3);
RUN;
May I know what exactly this code is doing here? as I can see we are using both PUT and INPUT and also why adding 19000000 ?
Without actual date I have to guess that someone is either adding or changing the century value of something that is not really a SAS date value.
It might help to print out some values of DATEF and DateZ
Hi @kajal_30
It seems that the objective is to get a character string that can be read as a valid SAS date.
For example, if DATEF is equal to "500612", you will get "19500612", that will be read as 06/12/1952.
The CALL SYMPUT statement computes a macrovariable that contains the last unformatted value of the variable DATE3.
Best,
Hello,
I think the author of this code was looking for the yearcutoff option :
%macro date_loop;
data have;
format a date9. i z2.;
do i=1 to 99;
a=input(cats(i,"0101"),yymmdd6.);
put a= a best.;
end;
run;
%mend;
option yearcutoff=1920;
%date_loop
option yearcutoff=1900;
%date_loop
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.