Hello,
I would like to generate a macro variable list using proc sql.
I am using calculated values to generate the list.
Is there a way to do this in the same step without generating the error (?):
"WARNING: INTO clause specifies fewer host variables than columns listed in the SELECT clause."
proc sql ;
select
length(strip(name)) as _length
,anydigit(name) as digit_pos
,cats(name,'=',substr(name, 1, calculated digit_pos-2))
into
:renamelistn separated by ' '
from
dictionary.columns
where libname='WORK' and memname='VSPE_FMT' and anydigit(name)>0 ;
%put &renamelistn. ;
quit ;Thank you!
Hello @mglogan Looks like you don't need this bit
/* length(strip(name)) as _length*/
/* ,anydigit(name) as digit_pos*/
So
proc sql ;
select
/* length(strip(name)) as _length*/
/* ,anydigit(name) as digit_pos*/
cats(name,'=',substr(name, 1, anydigit(name)-2))
into
:renamelistn separated by ' '
from
dictionary.columns
where libname='WORK' and memname='VSPE_FMT' and anydigit(name)>0 ;
%put &renamelistn. ;
quit ;
should do
What are trying to create?
If it is just the values from the third column then add two dummy target variables for the other columns
proc sql ;
select
length(strip(name)) as _length
,anydigit(name) as digit_pos
,cats(name,'=',substr(name, 1, calculated digit_pos-2))
into
:dummy
,:dummy
,:renamelistn separated by ' '
from
dictionary.columns
where libname='WORK' and memname='VSPE_FMT' and anydigit(name)>0
;
%put &renamelistn. ;
quit ;
Hello @mglogan Looks like you don't need this bit
/* length(strip(name)) as _length*/
/* ,anydigit(name) as digit_pos*/
So
proc sql ;
select
/* length(strip(name)) as _length*/
/* ,anydigit(name) as digit_pos*/
cats(name,'=',substr(name, 1, anydigit(name)-2))
into
:renamelistn separated by ' '
from
dictionary.columns
where libname='WORK' and memname='VSPE_FMT' and anydigit(name)>0 ;
%put &renamelistn. ;
quit ;
should do
Oh yes! Thank you!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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 save with the early bird rate—just $795!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.