Hello, Expert, I have a simple question. I established a query to store the value (which will be changed under specific condition), and then want to give this value to variable J which will be used by other Macros. I was using '&let' but system showed wrong. Can you give me some advice, still a newbee to SAS.
PROC SQL;
CREATE TABLE WORK.Number AS
SELECT (MAX(t1.'Primary ID'n)) FORMAT=BEST12. AS RowNum
FROM WORK.modeltraining_blocked t1;
QUIT;
%let j=int(number.Rownum/7);
proc print data=work.number.rownum;
To put the value from a SQL query into a macro variable, use the INTO : clause
PROC SQL;
SELECT int( MAX('Primary ID'n) / 7) into : J
FROM modeltraining_blocked;
QUIT;
To put the value from a SQL query into a macro variable, use the INTO : clause
PROC SQL;
SELECT int( MAX('Primary ID'n) / 7) into : J
FROM modeltraining_blocked;
QUIT;
PROC SQL;
SELECT MAX(t1.'Primary ID'n/7) FORMAT=BEST12. into :RowNum
FROM WORK.modeltraining_blocked t1;
QUIT;
%put &rownum.;
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.