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

This question is a continuation of a question I have asked earlier but it is a different problem hence I've started a new discussion.

I wanted to eliminate a list of variables from my data set. The below code is part of a macro.

proc sql noprint;

select strip(_NAME_) into : varlist separated by ' '

     from to_drop

     where _NAME_ ne '_TYPE_';

     where _NAME_ ne '_FREQ_';

quit;

data inputds_factor;

   set &input (drop=&varlist);

run;

When the above steps execute, I get the error below:


ERROR: The following columns were not found in the contributing tables: _NAME_.

WARNING: This SAS global statement is not supported in PROC SQL. It has been ignored.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: PROCEDURE SQL used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds


When I execute the code, outside the macro, I don't get this error. How can I overcome this problem?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Have you done a %put &varlist in the macro to see what the value of the list is? What does it look like?

Also you could suppress those two variables at creation time if desired and using proc means or summary with dataset options:

output out=to_drop (drop=_TYPE_ _FREQ_) <rest of output options> ;

How the data set to_drop is built may have something to do with the result.

View solution in original post

3 REPLIES 3
art297
Opal | Level 21

I'd think you'd get the error both inside and outside a macro. You have an extra semi-colon and 2 where statements.

Try:

proc sql noprint;

select strip(_NAME_) into : varlist separated by ' '

   from to_drop

     where _NAME_ ne '_TYPE_' and

           _NAME_ ne '_FREQ_'

  ;

quit;

Ksharp
Super User

  where _NAME_ not in  ('_TYPE_'  '_FREQ_')

ballardw
Super User

Have you done a %put &varlist in the macro to see what the value of the list is? What does it look like?

Also you could suppress those two variables at creation time if desired and using proc means or summary with dataset options:

output out=to_drop (drop=_TYPE_ _FREQ_) <rest of output options> ;

How the data set to_drop is built may have something to do with the result.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 985 views
  • 3 likes
  • 4 in conversation