Hi Everyone,
Can any one help me
I have library name called 'op' in the library i have a datasets looks like
abc_201301
abc_201302
abc_201303
abc_201304
.
.
.
.
abc_201801
abc_201802
abc_201803
abc_201804
abc_201805
abc_201806
abc_201807
abc_201808
abc_201809
till the last month
ex:if i ran a program the dataset today, it will create this year lastmonth(201809)
How can i show only last month dataset name
if the last month dataset is created show only last month dataset name ,if not created it should exit
Please give a skeleton program. I don't know what you mean by "exit". Do you mean end the sas session? Skip some other program steps?
Editted note. Here's something close to what I think you want:
%let dsname=op.abc_%sysfunc(intnx(month,%sysfunc(today()),-1),yymmn6.);
%macro existds(name);
%if %sysfunc(exist(&name)) %then 1;
%else 0
%mend existds;
%put Dataset &dsname exist dummy is %existds(&dsname);
The main thing here is, given today's date, constructing the data set name corresponding to last month (op.abc_201809). Above it's constructed in macro language. In a data step, it would look something like:
data _null_;
dsname=cats('op.abc_',put(intnx('month',today(),-1),yymmn6.));
d=exist(dsname);
put d=;
run;
What loop? Please show the code that implements the loop.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.