Reputation:
I have a sasdataset with a number of observations where one of the variables is called DATO.
This variable contains the Date that the observation was added to the dataset.
Previously i have used the following:
WHERE (DATE() - DATO) < 250;
To select which Observations to print, but this comes with issues. Previously i added observations monthly, but now i do it on daily basis.
I need to find a way to print out only observations which are from the first day of the last 8 months.
I can probably figure out the issue with the 8 months, but not how to select only the first day of the month. Any help would be greatly appreciated.
Upvotes: 1
Views: 662
Reputation: 12691
data _null_;
infile cards;
input DATO:date9.;
if day(DATO)=1 /* first of the month */
and DATO>intnx('MONTH',date(),-8) /* returns date shifted back 8 months */
then put DATO= date9.;
cards;
01JAN2013
02JAN2013
01FEB2013
01MAR2013
03MAR2013
;run;
results:
DATO=01JAN2013
DATO=01FEB2013
DATO=01MAR2013
Upvotes: 1