BookmarkSubscribeRSS Feed
kajal_30
Quartz | Level 8

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 ? 

3 REPLIES 3
ballardw
Super User

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

ed_sas_member
Meteorite | Level 14

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,

 

gamotte
Rhodochrosite | Level 12

Hello,

 

I think the author of this code was looking for the yearcutoff option :

 

https://documentation.sas.com/?docsetId=lesysoptsref&docsetTarget=n0yt2tjgsd5dpzn16wk1m3thcd3c.htm&d...

 

%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

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