BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10
proc sql;
 select name,sex,age into  :n  seperated by ', ' from sashelp.class
 where name='William';
quit;

%put &=n. ;
%put &=a. ;
%put &=b. ;

I want  name ,sex and age values in log window

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

Do you want the values in separate macro variables or in one macro variable?

s_lassen
Meteorite | Level 14

I assume what you want is something like this:

proc sql noprint;
 select name,sex,age into  :n,:s,:a from sashelp.class
 where name='William';
quit;

%put &=n. ;
%put &=a. ;
%put &=b. ;

I put in the NOPRINT option for the procedure, as I assume you do not want the print as well as the log lines.

 

The guide to SELECT ... INTO is here 

andreas_lds
Jade | Level 19

Storing data in macro-variables almost always leads to unnecessary difficult code. So, because i am curious, what are the next steps?

PaigeMiller
Diamond | Level 26

@BrahmanandaRao wrote:
proc sql;
 select name,sex,age into  :n  seperated by ', ' from sashelp.class
 where name='William';
quit;

%put &=n. ;
%put &=a. ;
%put &=b. ;

I want  name ,sex and age values in log window


Others have given valuable advice.

 

Please, @BrahmanandaRao, from now on let's get the terminology correct so we can all avoid confusion. You are not talking about a "macro". You are talking about macro variables. Do not call macro variables by the name "macro". A macro is something different.

--
Paige Miller
ballardw
Super User

@BrahmanandaRao wrote:
proc sql;
 select name,sex,age into  :n  seperated by ', ' from sashelp.class
 where name='William';
quit;

%put &=n. ;
%put &=a. ;
%put &=b. ;

I want  name ,sex and age values in log window


data _null_;
   set sashelp.class;
   put name sex age;
run;

SQL does not write much to the log. The data step Put statement will unless you provide a target File. Or use the PUTLOG statement to limit output to the log only.

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
  • 5 replies
  • 1066 views
  • 1 like
  • 6 in conversation