BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mglogan
Obsidian | Level 7

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!

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

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

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

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 ;

 

novinosrin
Tourmaline | Level 20

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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1817 views
  • 0 likes
  • 3 in conversation