want to KEEP variables with same suffix

Reply
Contributor
Posts: 34

want to KEEP variables with same suffix

data case;

*informat dateslen  datesnlen   datesvlen date9. ;

input dateslen $ datesnlen $ datesvlen $data4 $ 16.;

*format dateslen yymmdd10. datesnlen  ddmmyy10. datesvlen date9.;

Flavor="Cherry";

attrib Flavor format=$10.;

datalines;

01JAN1960 15JAN1960 08JUL2003 2015-09-06T11:40

02MAR1961 18FEB1962 04MAR2000 2015-09-06T11:40

25DEC2000 03JAN2001 09MAR1961 2015-09-06T11:40

;

run;

KEEP dateslen  datesnlen   datesvlen

HELP

Frequent Contributor
Posts: 115

Re: want to KEEP variables with same suffix

Hi, I copied the code of Tom and Art from a previous post:

/*tom's code*/

proc contents data=case out=contents(keep=name) noprint ; run;

proc sql noprint ;

select name into :keeplist separated by ' '

from contents

where upcase(name) like '%^len' escape '^'

;

quit;

data want ;

  set case (keep=&droplist);

run;

The following is Art's code

proc sql noprint;

  select name

    into :keep separated by ' '

      from dictionary.columns

        where upcase(name) like '%^len' escape '^' and

              libname eq "WORK" and

              memname eq "HAVE"

  ;

quit;

data want;

  set case (keep=&keep);

run;

Thank them if you like.

Regards,

Naveen Srinivasan

L&T Infotech

Super User
Super User
Posts: 7,725

Re: want to KEEP variables with same suffix

Alternatively, and what may help you further along the line is to think of your columns not in terms of descriptive data, but columns with additional descriptive data:

COL1 label="DATESLEN"

COL2 label="DATESNLEN"

COL3 label="DATESVLEN"

You can then refer to the data columns as COL1-COL3, or of COL{*}. 

Contributor
Posts: 34

Re: want to KEEP variables with same suffix

i have 15 different data set and in one dataset i have 250 varaiables..BUT NONE OF THE ABOVE ARE NOT SUITABLE FORM QUESTION

kool i am happy for your reply.

I got the Answer as well.  i m done .

Thanks,

Anita

Super User
Posts: 19,172

Re: want to KEEP variables with same suffix

Please mark the question answered if you have your answer Smiley Happy

Ask a Question
Discussion stats
  • 4 replies
  • 1423 views
  • 0 likes
  • 4 in conversation