BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Jonison
Fluorite | Level 6

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;

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

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;
PG

View solution in original post

4 REPLIES 4
PGStats
Opal | Level 21

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;
PG
Jonison
Fluorite | Level 6
Thank you!
smantha
Lapis Lazuli | Level 10

PROC SQL;
SELECT MAX(t1.'Primary ID'n/7) FORMAT=BEST12. into  :RowNum
FROM WORK.modeltraining_blocked t1;
QUIT;

 

%put &rownum.;

 

 

Jonison
Fluorite | Level 6
thank you!

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1262 views
  • 0 likes
  • 3 in conversation