Hi Team,
I need to create one base if the base name is >= 202004.. Is it possible?
I tried this code, but it put all the bases together.
DATA MIS;
SET LIB._MIS:;
RUN;
name of the bases:
lib.MIS_201910
lib.MIS_201911
lib.MIS_201912
lib.MIS_202001
lib.MIS_202002
lib.MIS_202003
lib.MIS_202004
lib.MIS_202005
lib.MIS_202006
lib.MIS_202007
lib.MIS_202008
lib.MIS_202009
lib.MIS_202010
lib.MIS_202011
lib.MIS_202012
lib.MIS_202101
lib.MIS_202102
lib.MIS_202103
Thanks!
Use double -- instead of single - check the link in the previous post for all the options.
Here is a reference that illustrates how to refer to variables and datasets in a short cut list:
https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html
Or create a macro variable from sashelp.vtables.
proc sql noprint;
select memname into :Table_list separated by " "
from sashelp.vtable where libname = "LIB" and memname >= "MIS_202004";
quit;
%put &table_list;
Can you assume the last one will always be the current month?
If so you could do something like:
set lib.mis_202004 - lib.mis_%sysfunc(today(), yymmn6.);
EDIT: corrected to remove PUTN(), thanks to @SASKiwi
Here is a reference that illustrates how to refer to variables and datasets in a short cut list:
https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html
Yes, the last one is the current month.
I tried, and this error appears:
ERROR: Required operator not found in expression: today()
ERROR: Argument 1 to function PUTN referenced by the %SYSFUNC or %QSYSFUNC macro function is not a number.
ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC argument list. Execution of %SYSCALL statement or %SYSFUNC
or %QSYSFUNC function reference is terminated.
ERROR: Missing numeric suffix on a numbered data set list (LIB.MIS_202004-LIB.MIS_).
This works better: %sysfunc(today(), yymmn6.);
the data format did not work.
ERROR: File LIB.MIS_202013.DATA does not exist.
ERROR: File LIB.MIS_202014.DATA does not exist.
ERROR: File LIB.MIS_202015.DATA does not exist.
ERROR: File LIB.MIS_202016.DATA does not exist.
ERROR: File LIB.MIS_202017.DATA does not exist.
ERROR: File LIB.MIS_202018.DATA does not exist.
ERROR: File LIB.MIS_202019.DATA does not exist.
ERROR: File LIB.MIS_202020.DATA does not exist.
ERROR: File LIB.MIS_202021.DATA does not exist.
ERROR: File LIB.MIS_202022.DATA does not exist.
Use double -- instead of single - check the link in the previous post for all the options.
Here is a reference that illustrates how to refer to variables and datasets in a short cut list:
https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html
Or create a macro variable from sashelp.vtables.
proc sql noprint;
select memname into :Table_list separated by " "
from sashelp.vtable where libname = "LIB" and memname >= "MIS_202004";
quit;
%put &table_list;
DATA WANT; set lib.MIS_202004--LIB.MIS_%sysfunc(today(), yymmn6.); run;
22
76
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, _DATA_, _LAST_, _NULL_.
ERROR 76-322: Syntax error, statement will be ignored.
Not working 😞
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.