I want to use the month and year from today's date and use that as a column in SQL table .
Below is the code that I am using to get the month and year :
data _null_;
CUR_MONTH =today();
format CUR_MONTH yymmn6.;
put CUR_MONTH;
run;
Now , I want to use the variable CUR_MONTH in SELECT statement , something like :
PROC SQL;
SELECT
&CUR_MONTH , ID , NAME FROM ABC;
But , I get Error ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,
a missing value, (, *, +, -, ALL, BTRIM, CALCULATED, CASE, DISTINCT, EXISTS, INPUT, NOT, PUT, SUBSTRING, TRANSLATE,
UNIQUE, USER, ^, ~.
Can someone please guide . Thanks.
Try:
data _null_;
call symputx('CUR_MONTH', put(today(), yymmn6.));
run;This will initialize CUR_MONTH as a macro variable, which you can use in the subsequent PROC SQL statement.
Try:
data _null_;
call symputx('CUR_MONTH', put(today(), yymmn6.));
run;This will initialize CUR_MONTH as a macro variable, which you can use in the subsequent PROC SQL statement.
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.