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

Hello,

I have a dataset which has many variables. I don't need those variables which has 'f' in the last position of the name. For example, the names of those variables are like wagef, levelf, posf.

Thanks for help.

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Combination of Patrick and LinLin.

proc sql noprint;

   select name into : names separated by ' '

   from dictionary.columns

   where libname='WORK' and memname='HAVE' and upcase(name) like '%F' ;

quit;

Ksharp

View solution in original post

3 REPLIES 3
Linlin
Lapis Lazuli | Level 10

data have;

  input aaf bbbf ccc;

  cards;

  1 2 4

  2 3 8

  ;

proc sql noprint;

   select name into : names separated by ' '

   from dictionary.columns

   where libname='WORK' and memname='HAVE' and lowcase(substr(name,length(name),1))='f';

quit;

data want;

   set have (drop=&names);

  run;

  proc print;run;

                                          Obs    ccc

                                             1      4

                                             2      8

Linlin

Patrick
Opal | Level 21

data have;
   wagef=1;
   wage=1;
   wagefn=1;
   xageF=1;
run;

%let dellist=;
proc sql;
   select name into :dellist separated by ','
   from dictionary.columns
   where libname='WORK' and memname='HAVE' and upcase(name) like '%F'
   ;
   %macro _del;
      %if %bquote(&dellist) ne %bquote() %then
      %do;
         alter table work.have
            drop &dellist
         ;
      %end;
   %mend;
   %_del
quit;

proc contents data=work.have;
quit;

Ksharp
Super User

Combination of Patrick and LinLin.

proc sql noprint;

   select name into : names separated by ' '

   from dictionary.columns

   where libname='WORK' and memname='HAVE' and upcase(name) like '%F' ;

quit;

Ksharp

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!

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
  • 1158 views
  • 6 likes
  • 4 in conversation