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 (March 2007, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 21 Mar 2007 08:41:45 -0700
Reply-To:   "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Subject:   Re: A Simple DATA MANUPULATING QUESTION
Comments:   To: Rathindronath <mehedisas@YAHOO.COM>
In-Reply-To:   <200703211353.l2LAm8g5028043@mailgw.cc.uga.edu>
Content-Type:   text/plain; charset=iso-8859-1

> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On > Behalf Of Rathindronath > Sent: Wednesday, March 21, 2007 6:54 AM > To: SAS-L@LISTSERV.UGA.EDU > Subject: A Simple DATA MANUPULATING QUESTION > > I have a dataset as follows: > > Player Game1 Game2 > 1 1 0 > 1 1 0 > 1 0 0 > 2 1 D > 2 D D > 2 0 > 2 0 1 > 3 0 1 > 3 0 1 > > > Need a following dataset where if a player scores atleast > one 1 then that player Score 1 for that Game else it will > score 0 for that Game: > > Result: > > Player Game1 Game2 > 1 1 0 > 2 1 1 > 3 0 1 > >

Rathindronath,

I see you have received some SQL solutions. Here is a data step solution.

data have; infile cards missover; input Player Game1 $ Game2 $; cards; 1 1 0 1 1 0 1 0 0 2 1 D 2 D D 2 0 2 0 1 3 0 1 3 0 1 ; run; data want; set have (rename=(game1=_game1 game2=_game2)); by player;

if first.player then do; game1='0'; game2='0'; retain game1 game2; end;

if _game1 EQ '1' then game1='1'; if _game2 EQ '1' then game2='1';

if last.player then output; drop _: ; run; proc print; run;

Hope this is helpful,

Dan

Daniel J. Nordlund Research and Data Analysis Washington State Department of Social and Health Services Olympia, WA 98504-5204


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