LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (September 2008, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 9 Sep 2008 11:58:03 -0500
Reply-To:     Mary <mlhoward@avalon.net>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Mary <mlhoward@AVALON.NET>
Subject:      Re: KEEP DROP array variables
Comments: To: "jlee8071@gmail.com" <jlee8071@GMAIL.COM>
Content-Type: text/plain; format=flowed; charset="iso-8859-1";
              reply-type=original

This seems to work:

data test; informat var1 var2 var3 var4 $2.; infile cards; input var1 var2 var3 var4; cards; AA BB BC DD DD CC DC AA ; run;

%macro macrowrapper;

%let keeplist= ;

proc sql noprint; select max(varnum) into: varnum separated by " " from dictionary.columns where libname eq "WORK" and memname eq "TEST"; quit;

%put &varnum;

%do i=1 %to &varnum; proc sql noprint; select NAME into: VarList1 separated by " " from dictionary.columns where libname eq "WORK" and memname eq "TEST" and varnum= &i; quit; %put &varlist1;

proc sql; select count(&varlist1) into :countc from test where &varlist1='DD'; quit; %put &countc;

%if &countc > 0 %then %do; %let keeplist= &keeplist &varlist1; %end; %end;

%put &keeplist;

data newtest; set test; keep &keeplist; run;

%mend macrowrapper;

%macrowrapper;

-Mary ----- Original Message ----- From: jlee8071@gmail.com To: SAS-L@LISTSERV.UGA.EDU Sent: Monday, September 08, 2008 11:53 PM Subject: KEEP DROP array variables

Dear SAS users,

I know that one cannot use KEEP or DROP with array variables. But is there a way to resolve this?

Here is my code. It doesn't work of course.

do i=1 to 6651; if (snps[i] = "DD") then do; keep snps[i]; end; end;

The original dataset has 6651 variables and I only want to keep those variables who has values "DD".

Thank you for the help. claus


Back to: Top of message | Previous page | Main SAS-L page