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.
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!
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.