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!
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.