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 08:31:28 -0400
Reply-To:     "Lanoue, Jacques" <JLanoue@MANNKINDCORP.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Lanoue, Jacques" <JLanoue@MANNKINDCORP.COM>
Subject:      Re: Deleting column based on values in column
In-Reply-To:  A<EE977A7ACA588B428067FF35914D38E90330D8D7@SXGM-401.fg.rbc.com>
Content-Type: text/plain; charset="iso-8859-1"

Jim, The code would look like:

*Step 1; %let instruction=*No Drop of variable; Data _null_; Set Mydata; If C'=c' then call symput(instruction,'Drop C'); Run; *Step 2; Data Mydata; Set Mydata; &instruction; Run;

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Lane, Jim Sent: Tuesday, September 09, 2008 8:26 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Deleting column based on values in column

Hi, Jacques

Right you are. I'm typing faster than I'm thinking this morning. I really ought to have written:

if C="c" then do; drop C; end;

Regards, Jim Lane

-----Original Message----- From: Lanoue, Jacques [mailto:JLanoue@mannkindcorp.com] Sent: 2008, September, 09 8:00 AM To: Lane, Jim; SAS-L@LISTSERV.UGA.EDU Subject: RE: Re: Deleting column based on values in column

Jim, Suren,

The instruction Drop (also Keep) is not working like a function;

You can do this in two steps:

1 Identify the variables that you want to Drop.

2 Drop the variables

Thanks, Jacques Lanoue Phone: (201) 983-5034 BlackBerry: (203) 224-0663 Fax: (201) 450-9982

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Lane, Jim Sent: Tuesday, September 09, 2008 7:49 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Deleting column based on values in column

Hi, Suren

First let's get some terminology straight. In SAS you delete rows (or observations) and you drop columns (or variables).

If I've understood your example correctly the SAS code would be:

if C="c" then drop C;

The result of that would be a dataset like this:

A B 1 2 1 3 1 4 1 6

Is that what you want?

Regards, Jim Lane

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Suren gc Sent: 2008, September, 08 4:24 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Deleting column based on values in column

I have a dataset like this: A B C 1 2 a 1 3 b 1 4 c 1 6 d

Is there a way I can write SAS program where the comparison is made on the value of the column and manipulation is made to the column. For instance, if Column C has value c, then deleted the column containing c rather than deleting the row. Thanks, Suren _______________________________________________________________________

This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations. Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized. If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately.

Ce courrier électronique est confidentiel et protégé. L'expéditeur ne renonce pas aux droits et obligations qui s'y rapportent. Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il contient par une personne autre que le (les) destinataire(s) désigné(s) est interdite. Si vous recevez ce courrier électronique par erreur, veuillez m'en aviser immédiatement, par retour de courrier électronique ou par un autre moyen. _______________________________________________________________________

This e-mail may be privileged and/or confidential, and the sender does not waive any related rights and obligations. Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized. If you received this e-mail in error, please advise me (by return e-mail or otherwise) immediately.

Ce courrier électronique est confidentiel et protégé. L'expéditeur ne renonce pas aux droits et obligations qui s'y rapportent. Toute diffusion, utilisation ou copie de ce message ou des renseignements qu'il contient par une personne autre que le (les) destinataire(s) désigné(s) est interdite. Si vous recevez ce courrier électronique par erreur, veuillez m'en aviser immédiatement, par retour de courrier électronique ou par un autre moyen.


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