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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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
  • 621 views
  • 0 likes
  • 4 in conversation