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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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