Hi SAS experts,
For the below codes, I don't understand why &varlist only catched “height”, and low only catched '1'. It supposed to be "height weight" for &varlist; and "1.0 25" for &lowlist. Any thoughts would be appreciated!
Thanks in advance~
data a;
input var $ low high;
cards;
height 1.0 2.0
weight 25 200
;
run;
proc sql;
select Var, low, high into:varlist,:lowlist,:highlist separated by ' '
from a;
quit;
%put varlist: &varlist ---
lowlist: &lowlist ---
highlist:&highlist;
Note that it does work for the last entry.
The portion of code " separated by ' ' " is only applied to the last set of items which is why that one shows correctly. Specify it for every list if you want to store multiple items in each list, otherwise it stores only the first value.
This works.
proc sql;
select Var, low, high into
:varlist separated by " ",
:lowlist separated by " ",
:highlist separated by ' '
from a;
quit;
%put varlist: &varlist ---
lowlist: &lowlist ---
highlist:&highlist;
@Cecillia_Mao wrote:
Hi SAS experts,
For the below codes, I don't understand why &varlist only catched “height”, and low only catched '1'. It supposed to be "height weight" for &varlist; and "1.0 25" for &lowlist. Any thoughts would be appreciated!
Thanks in advance~
data a; input var $ low high; cards; height 1.0 2.0 weight 25 200 ; run; proc sql; select Var, low, high into:varlist,:lowlist,:highlist separated by ' ' from a; quit; %put varlist: &varlist --- lowlist: &lowlist --- highlist:&highlist;
Note that it does work for the last entry.
The portion of code " separated by ' ' " is only applied to the last set of items which is why that one shows correctly. Specify it for every list if you want to store multiple items in each list, otherwise it stores only the first value.
This works.
proc sql;
select Var, low, high into
:varlist separated by " ",
:lowlist separated by " ",
:highlist separated by ' '
from a;
quit;
%put varlist: &varlist ---
lowlist: &lowlist ---
highlist:&highlist;
@Cecillia_Mao wrote:
Hi SAS experts,
For the below codes, I don't understand why &varlist only catched “height”, and low only catched '1'. It supposed to be "height weight" for &varlist; and "1.0 25" for &lowlist. Any thoughts would be appreciated!
Thanks in advance~
data a; input var $ low high; cards; height 1.0 2.0 weight 25 200 ; run; proc sql; select Var, low, high into:varlist,:lowlist,:highlist separated by ' ' from a; quit; %put varlist: &varlist --- lowlist: &lowlist --- highlist:&highlist;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.