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 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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