Date: Wed, 20 Dec 2006 10:31:04 -0600
Reply-To: Suhong Tong <sophidt@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Suhong Tong <sophidt@HOTMAIL.COM>
Subject: Re: What's wrong with my code?
In-Reply-To: <BAY103-F291BCB0AA5A738D0921822B0CF0@phx.gbl>
Content-Type: text/plain; format=flowed
Thank you all for helping me de-bug my program. David, you are right, it is
the code that *not* posted that cause me trouble, I found it and it's a
downstream macro, which is not so obvious to see.
Thank you all people with sharp brains.
Have a great holiday!!
Suhong
>From: David L Cassell <davidlcassell@MSN.COM>
>Reply-To: David L Cassell <davidlcassell@MSN.COM>
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Re: What's wrong with my code?
>Date: Tue, 19 Dec 2006 22:08:12 -0800
>
>sophidt@HOTMAIL.COM replied:
>>>
>>>On Tue, 19 Dec 2006 20:27:17 -0600, Suhong Tong <sophidt@HOTMAIL.COM>
>>>wrote:
>>>
>>> >This really bothers me. The objective for this coding is that combine
>>> >race=4 and 5 as one class, if race =97 and 98, which is don't knows,
>>>then
>>> >impute with value of RACEETHA. It looked pretty simple, and I did
>>>similar
>>> >recodings on other items w/o any problem, but it just won't work for
>>>this
>>> >one, even with the code toby provided below. It seemed SAS ignore my
>>> >coding.
>>>
>>>Y
>>
>>ou are leaving out too much. I would like to see some sample input data
>>and
>>>a complete DATA step having the problem (not just a fragment). Also, you
>>>are
>>>not showing the immediate output, but rather output from a PROC FREQ
>>>downstream. Where is the PROC FREQ code?
>>>
>>>You may find that the task of putting together a complete presentation
>>>will
>>>actually reveal the problem.
>>>
>>> >
>>> >Here is the simplified version of code verification and re-arranged
>>>code:
>>> >
>>> >IF RACE IN ( 4, 5 ) THEN IMPETHN = 4;
>>> > ELSE IF RACE = 95 THEN IMPETHN = 5;
>>> > ELSE IF RACE IN ( 97, 98 ) THEN IMPETHN = RACEETHA ;
>>> > ELSE IMPETHN=RACE;
>>> > IF RACE IN ( 97, 98 ) THEN IMPETHN_FLG = 1 ;
>>> >
>>> > People who currently smoke PIPE, BY REGION
>>> > 215
>>> > 13:53
>>> >Tuesday, December 19, 2006
>>> >
>>> > The FREQ Procedure
>>> >
>>> >
>>>Cumulative
>>> > Cumulative
>>> > IMPETHN RACE RACEETHA Frequency Percent
>>>Frequency
>>> > Percent
>>> >
>>> >��������������������������������������������������������������������������������
>>> > 1 1 1 1263 10.30
>>>1263
>>> > 10.30
>>> > 1 2 2 16 0.13
>>>1279
>>> > 10.43
>>> > 1 6 2 2 0.02
>>>1281
>>> > 10.45
>>> > 1 95 2 2 0.02
>>>1283
>>> > 10.47
>>> > 1 97 1 7 0.06
>>>1290
>>> > 10.52
>>> > 1 98 1 1 0.01
>>>1291
>>> > 10.53
>>> > 2 1 1 16 0.13
>>>1307
>>> > 10.66
>>> > 2 2 2 9918 80.92
>>>11225
>>> > 91.58
>>> > 2 4 2 1 0.01
>>>11226
>>> > 91.59
>>> > 2 5 2 3 0.02
>>>11229
>>> > 91.61
>>> > 2 6 2 11 0.09
>>>11240
>>> > 91.70
>>> > 2 95 2 25 0.20
>>>11265
>>> > 91.91
>>> > 2 97 2 36 0.29
>>>11301
>>> > 92.20
>>> > 2 98 2 4 0.03
>>>11305
>>> > 92.23
>>> > 3 1 1 1 0.01
>>>11306
>>> > 92.24
>>> > 3 2 2 3 0.02
>>>11309
>>> > 92.27
>>> > 3 3 3 578 4.72
>>>11887
>>> > 96.98
>>> > 3 95 2 3 0.02
>>>11890
>>> > 97.01
>>> > 3 97 3 3 0.02
>>>11893
>>> > 97.03
>>> > 4 1 1 1 0.01
>>>11894
>>> > 97.04
>>> > 4 2 2 1 0.01
>>>11895
>>> > 97.05
>>> > 4 4 2 86 0.70
>>>11981
>>> > 97.75
>>> > 4 5 2 12 0.10
>>>11993
>>> > 97.85
>>> > 4 95 2 2 0.02
>>>11995
>>> > 97.86
>>> > 5 1 1 1 0.01
>>>11996
>>> > 97.87
>>> > 5 2 2 15 0.12
>>>12011
>>> > 97.99
>>> > 5 3 3 1 0.01
>>>12012
>>> > 98.00
>>> > 5 6 2 2 0.02
>>>12014
>>> > 98.02
>>> > 5 95 2 109 0.89
>>>12123
>>> > 98.91
>>> > 6 1 1 1 0.01
>>>12124
>>> > 98.91
>>> > 6 2 2 7 0.06
>>>12131
>>> > 98.97
>>> > 6 4 2 1 0.01
>>>12132
>>> > 98.98
>>> > 6 5 2 1 0.01
>>>12133
>>> > 98.99
>>> > 6 6 2 121 0.99
>>>12254
>>> > 99.98
>>> > 6 95 2 3 0.02
>>>12257
>>> > 100.00
>>> >
>>> >
>>> >What could be wrong? Thanks,
>>> >
>>> >Su
>>> >
>>> >
>>> >>From: "toby dunn" <tobydunn@hotmail.com>
>>> >>To: sophiDT@HOTMAIL.COM, SAS-L@LISTSERV.UGA.EDU
>>> >>Subject: RE: What's wrong with my code?
>>> >>Date: Tue, 19 Dec 2006 22:30:12 +0000
>>> >>
>>> >>Assuming yoru business logic is correct you may be better served by
>>>doing
>>> >>this if your business logic isnt correct then perhaps this recoded
>>>example
>>> >>may better help you find the mistake.:
>>> >>
>>> >>IF RACE IN ( 4 5 ) THEN IMPETHN = 4 ;
>>> >>E LSE IF RACE IN ( 95 ) THEN IMPETHN = 5 ;
>>> >>ELSE IF RACE IN ( 97 98 ) THEN IMPETHN = RACEETHA ;
>>> >>ELSE IMPETHN = RACE ;
>>> >>
>>> >>IF RACE IN ( 97 98 ) THEN IMPETHN_FLG = 1 ;
>>> >>
>>> >>
>>> >>Toby Dunn
>>> >>
>>> >>To sensible men, every day is a day of reckoning. ~John W. Gardner
>>> >>
>>> >>The important thing is this: To be able at any moment to sacrifice
>>>that
>>> >>which we are for what we could become. ~Charles DuBois
>>> >>
>>> >>Don't get your knickers in a knot. Nothing is solved and it just makes
>>>you
>>> >>walk funny. ~Kathryn Carpenter
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>
>>> >>From: Sophia Tong <sophiDT@HOTMAIL.COM>
>>> >>Reply-To: Sophia Tong <sophiDT@HOTMAIL.COM>
>>> >>To: SAS-L@LISTSERV.UGA.EDU
>>> >>Subject: What's wrong with my code?
>>> >>Date: Tue, 19 Dec 2006 17:17:28 -0500
>>> >>
>>> >>Dear SAS-L experts,
>>> >>
>>> >>I am lost with this code and couldn't figure out what's wrong.
>>> >>Here is my code:
>>> >> IF RACE IN (4, 5) THEN IMPETHN=4;
>>> >> ELSE IF RACE=95 THEN IMPETHN=5;
>>> >> ELSE IF RACE IN (97, 98) THEN DO;
>>> >> IMPETHN=RACEETHA;
>>> >> IMPETHN_FLG=1;
>>> >> END;
>>> >> ELSE IMPETHN=RACE;
>>> >>
>>> >>The results is a totally mess:
>>> >> People who currently smoke PIPE, BY
>>>REGION
>>> >> 211
>>> >> 13:53
>>> >>Tuesday, December 19, 2006
>>> >>
>>> >> The FREQ Procedure
>>> >>
>>> >>
>>> >>Cumulative Cumulative
>>> >>IMPETHN RACE RACEETHA IMPETHN_FLG Frequency Percent
>>> >>Frequency Percent
>>> >>ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
>>> >> 1 1 1 . 1261 10.29
>>> >>1261 10.29
>>> >> 1 1 1 1 2 0.02
>>> >>1263 10.30
>>> >> 1 2 2 . 16 0.13
>>> >>1279 10.43
>>> >> 1 6 2 . 2 0.02
>>> >>1281 10.45
>>> >> 1 95 2 . 2 0.02
>>> >>1283 10.47
>>> >> 1 97 1 1 7 0.06
>>> >>1290 10.52
>>> >> 1 98 1 1 1 0.01
>>> >>1291 10.53
>>> >> 2 1 1 . 16 0.13
>>> >>1307 10.66
>>> >> 2 2 2 . 9910 80.85
>>> >>11217 91.52
>>> >> 2 2 2 1 8 0.07
>>> >>11225 91.58
>>> >> 2 4 2 . 1 0.01
>>> >>11226 91.59
>>> >> 2 5 2 . 3 0.02
>>> >>11229 91.61
>>> >> 2 6 2 . 10 0.08
>>> >>11239 91.69
>>> >> 2 6 2 1 1 0.01
>>> >>11240 91.70
>>> >> 2 95 2 . 24 0.20
>>> >>11264 91.90
>>> >> 2 95 2 1 1 0.01
>>> >>11265 91.91
>>> >> 2 97 2 1 36 0.29
>>> >>11301 92.20
>>> >> 2 98 2 1 4 0.03
>>> >>11305 92.23
>>> >> 3 1 1 . 1 0.01
>>> >>11306 92.24
>>> >> 3 2 2 . 3 0.02
>>> >>11309 92.27
>>> >> 3 3 3 . 578 4.72
>>> >>11887 96.98
>>> >> 3 95 2 . 3 0.02
>>> >>11890 97.01
>>> >> 3 97 3 1 3 0.02
>>> >>11893 97.03
>>> >> 4 1 1 . 1 0.01
>>> >>11894 97.04
>>> >> 4 2 2 . 1 0.01
>>> >>11895 97.05
>>> >> 4 4 2 . 86 0.70
>>> >>11981 97.75
>>> >> 4 5 2 . 12 0.10
>>> >>11993 97.85
>>> >> 4 95 2 . 2 0.02
>>> >>11995 97.86
>>> >> 5 1 1 . 1 0.01
>>> >>11996 97.87
>>> >> 5 2 2 . 15 0.12
>>> >>12011 97.99
>>> >> 5 3 3 . 1 0.01
>>> >>12012 98.00
>>> >> 5 6 2 . 2 0.02
>>> >>12014 98.02
>>> >> 5 95 2 . 109 0.89
>>> >>12123 98.91
>>> >> 6 1 1 . 1 0.01
>>> >>12124 98.91
>>> >> 6 2 2 . 7 0.06
>>> >>12131 98.97
>>> >> 6 4 2 . 1 0.01
>>> >>12132 98.98
>>> >> 6 5 2 . 1 0.01
>>> >>12133 98.99
>>> >> 6 6 2 . 121 0.99
>>> >>12254 99.98
>>> >> 6 95 2 . 3 0.02
>>> >>12257 100.00
>>> >>
>>> >>Sorry for the output, you can copy and past this part in word to see
>>> >>better.
>>> >>
>>> >>Thanks,
>>> >>
>>> >>Suhong
>
>>
>>Howard,
>>
>>Thank you for tackling my problem, which remind me just test a
>>sub-dataset.
>>
>>but it is still puzzles me. I did a subset of my data, just keep RACE and
>>RACEETHA, then use the same set of the code, it works fine, but won't
>>work
>>with the complete data set. I never had such a thing before. Any idea?
>>
>>Thanks,
>>
>>Su
>
>I agree with Howard. (As usual!) I think the problem is *not*
>with the code you are showing us, but with code which you
>are *not* showing us.
>
>I am going to gaze into my crystal ball and see... I see a problem
>with your names for your data sets. Either you are giving the
>wrong data set name to your PROC FREQ step, or you have an
>error in your data step code that causes SAS to not over-write
>a previous data set with your new one, so you are not using the
>data set you thought you were.
>
>But divination is a very fuzzy area, so you ought to check your
>logs just so you can show me I am totally out to lunch. :-)
>
>HTH,
>David
>--
>David L. Cassell
>mathematical statistician
>Design Pathways
>3115 NW Norwood Pl.
>Corvallis OR 97330
>
>_________________________________________________________________
>Find sales, coupons, and free shipping, all in one place! MSN Shopping
>Sales & Deals
>http://shopping.msn.com/content/shp/?ctid=198,ptnrid=176,ptnrdata=200639
_________________________________________________________________
Get live scores and news about your team: Add the Live.com Football Page
www.live.com/?addtemplate=football&icid=T001MSN30A0701
|