what does
put(fdate+1,date9.) mean?
what does it mean to add 1 here?
say fdate is 31Aug2021
A SAS Date is an integer. So adding 1 will give you the next day.
The put statement converts the numeric SAS variable into character.
Assuming fdate is a date value (i.e. number of days since 01jan1960), then to represent 31aug2021, the underlying value of date is 22523. That can be revealed by running this code:
data _null_;
fdate='31aug2021'd;
put fdate=;
put fdate=date9. ;
run;
which generates this log:
6761 data _null_;
6762 fdate='31aug2021'd;
6763 put fdate=;
6764 put fdate=date9.;
6765 run;
fdate=22523
fdate=31AUG2021
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
But you ask about the put function (unlike the put statements above). AS @PeterClemmensen says, it calculates the first argument (i.e. adding 1 to the value 22523, getting 22524), and converts it to a character string using the date9. format, yielding the character "01sep2021":
data _null_;
fdate='31aug2021'd;
z=put(fdate+1,date9.);
put z=;
run;
Run these programs and take a look at the log.
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!
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.