BookmarkSubscribeRSS Feed
xxformat_com
Barite | Level 11

As far as I know it is not possible to use "not" with <varname>: to list a series of variable not starting with.

In other words, it is not possible to do this:

data tmp;
x1=1;
x2=2;
y1=1;
y2=2;
run;

proc print data=tmp;
    var not(x:) x:;
run;

We can still use a macro variable:

data tmp;
x1=1;
x2=2;
y1=1;
y2=2;
run;

proc sql noprint;
    select name into: notx separated by ' '
    from dictionary.columns
    where libname='WORK' and
          memname='TMP' and
          upcase(name) not like 'X%';
quit;  

proc print data=tmp;
    var &notx. x:;
run;    

Would you have any other suggestion?

1 REPLY 1
FreelanceReinh
Jade | Level 19

Hi @xxformat_com,

 

In your particular example you could use

proc print data=tmp;
var y: x:;
run;

or

proc print data=tmp;
id y:;
run;

Other forms of variable lists might be applicable to different cases.

 

The DROP= dataset option can exclude variable lists:

proc print data=have(drop=x:);
run;

In your example it could be used in a DATA step view:

data v / view=v;
set tmp(drop=x:);
set tmp;
proc print;
run;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 54 views
  • 0 likes
  • 2 in conversation