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

sas-innovate-white.png

🚨 Early Bird Rate Extended!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Lock in the best rate now before the price increases on April 1.

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
  • 1544 views
  • 0 likes
  • 3 in conversation