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 1996, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 8 Mar 1996 09:23:55 -0600
Reply-To:     txplltw@UABCVSR.CVSR.UAB.EDU
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Todd Weiss <txplltw@UABCVSR.CVSR.UAB.EDU>
Subject:      Code Reduction

Hello Folks,

There maybe giggling and laughing when showing the following but this problem is a little trickier than it looks. I have 4 data sets(i.e. patfung patprot patvirus patbact) containing observations using the code below. Would anyone be willing to share a more parsimonious code solution for obtaining the same observations in these 4 data sets(kind and number) using either data step or sql.

Thanks for any suggestions.

Todd Weiss Dept of Surgery UAB Birimingham, AL

The data set looks like the following:

The SAS System 08:14 Friday, March 8, 1996 10

OBS INSTITUT PATNUM RETX INFDATE INFECT INT_FUP FUNGUS INT_FUNG PROTOZOA INT_PROT VIRUS INT_VIR BACTERIA INT_BACT

1 ACH 0001 02/09/93 1.0 1.5113 . . . . 1 1.0842 . . 2 ACH 0002 . 0.0 18.7930 0 18.7930 0 18.7930 0 18.7930 0 18.7930 3 ACH 0003 . 0.0 20.4357 0 20.4357 0 20.4357 0 20.4357 0 20.4357 4 ACH 0004 03/15/94 1.0 18.1030 . . . . . . 1 8.5423 5 ACH 0005 09/24/93 1.0 15.4089 . . . . . . 1 0.1971 6 ACH 0008 09/16/93 1.0 15.7703 . . . . . . 1 0.2957 7 ACH 0008 10/03/93 1.0 15.7703 . . . . . . 1 0.8542 8 ACH 0008 10/16/93 1.0 15.7703 . . . . 1 1.2813 . . 9 ACH 0008 10/25/93 1.0 15.7703 . . . . . . 1 1.5770 10 ACH 0009 12/12/94 1.0 13.7991 . . . . . . 1 13.1748 11 ACH 0010 . 0.0 14.1605 0 14.1605 0 14.1605 0 14.1605 0 14.1605 12 ACH 0011 . 0.0 14.8176 0 14.8176 0 14.8176 0 14.8176 0 14.8176 13 ACH 0012 11/23/93 1.0 15.4747 . . . . 1 2.2341 . . 14 ACH 0012 02/26/94 1.0 15.4747 . . . . . . 1 5.3553 15 ACH 0012 12/17/94 1.0 15.4747 . . . . . . 1 15.0147 16 ACH 0013 10/31/93 1.0 14.2590 . . . . . . 1 0.2628 17 ACH 0013 11/03/93 1.0 14.2590 . . . . . . 1 0.3614 18 ACH 0014 11/12/93 1.0 13.6676 . . . . . . 1 0.0657 19 ACH 0014 11/29/93 1.0 13.6676 . . . . . . 1 0.6242 20 ACH 0014 12/05/94 1.0 13.6676 . . . . . . 1 12.8134 21 ACH 0015 11/17/93 1.0 13.4705 . . . . . . 1 0.0329 22 ACH 0015 11/22/93 1.0 13.4705 1 0.1971 . . . . . . 23 ACH 0015 11/25/93 1.0 13.4705 . . . . . . 1 0.2957 24 ACH 0015 11/28/93 1.0 13.4705 . . . . . . 1 0.3943 25 ACH 0016 12/08/93 1.0 12.9120 . . . . . . 1 0.1643 26 ACH 0016 05/10/94 1.0 12.9120 . . . . 1 5.1911 . . 27 ACH 0016 12/03/94 1.0 12.9120 . . . . . . 1 11.9920 28 ACH 0017 12/07/93 1.0 12.9448 . . . . . . 1 0.1643 29 ACH 0017 12/19/93 1.0 12.9448 . . . . . . 1 0.5585 30 ACH 0018 12/08/93 1.0 0.6571 . . . . . . 1 0.2957 31 ACH 0018 12/13/93 1.0 0.6571 . . . . . . 1 0.4600 32 ACH 0018 12/17/93 1.0 0.6571 . . . . . . 1 0.5914 33 ACH 0019 02/10/94 1.0 5.1254 . . . . . . 1 0.1314 34 ACH 0019 02/28/94 1.0 5.1254 . . . . . . 1 0.7228 35 ACH 0019 03/15/94 1.0 5.1254 . . . . . . 1 1.2156 36 ACH 0019 03/20/94 1.0 5.1254 . . . . . . 1 1.3799 37 ACH 0019 03/21/94 1.0 5.1254 . . . . 1 1.4128 . . 38 ACH 0019 03/31/94 1.0 5.1254 . . . . . . 1 1.7413 39 ACH 0019 05/17/94 1.0 5.1254 . . . . 1 3.2855 . . 40 ACH 0020 03/23/94 1.0 9.4951 . . . . . . 1 0.1971 41 ACH 0020 03/31/94 1.0 9.4951 . . . . 1 0.4600 . . 42 ACH 0020 12/08/94 1.0 9.4951 . . . . . . 1 8.7394 43 ACH 0021 08/19/94 1.0 4.7311 . . . . . . 1 0.3285 44 ACH 0021 08/26/94 1.0 4.7311 . . . . . . 1 0.5585 45 ACH 0023 . 0.0 5.9139 0 5.9139 0 5.9139 0 5.9139 0 5.9139 46 ACH 0026 . 0.0 3.3512 0 3.3512 0 3.3512 0 3.3512 0 3.3512 47 ACH 0027 12/10/94 1.0 0.9199 . . . . . . 1 0.2300 48 ACH 0031 . 0.0 1.2485 0 1.2485 0 1.2485 0 1.2485 0 1.2485 49 CCF 0001 . 0.0 15.7703 0 15.7703 0 15.7703 0 15.7703 0 15.7703 50 CCF 0002 . 0.0 14.8504 0 14.8504 0 14.8504 0 14.8504 0 14.8504 51 CCF 0003 . 0.0 14.0619 0 14.0619 0 14.0619 0 14.0619 0 14.0619 52 CCF 0004 . 0.0 10.3493 0 10.3493 0 10.3493 0 10.3493 0 10.3493 53 CCF 0005 08/30/94 1.0 0.8542 . . . . . . 1 0.8542 54 CCF 0006 . 0.0 2.1027 0 2.1027 0 2.1027 0 2.1027 0 2.1027 55 CCF 0007 . 0.0 0.4271 0 0.4271 0 0.4271 0 0.4271 0 0.4271 56 CCF 0008 . 0.0 1.1828 0 1.1828 0 1.1828 0 1.1828 0 1.1828 57 CGC 0001 . 0.0 0.1971 0 0.1971 0 0.1971 0 0.1971 0 0.1971 58 CGC 0002 . 0.0 0.0000 0 0.0164 0 0.0164 0 0.0164 0 0.0164 59 CGC 0003 06/14/93 1.0 19.3844 . . . . . . 1 0.8214 60 CGC 0007 12/18/93 1.0 14.5219 . . . . 1 2.1027 . . 61 CGC 0007 04/21/94 1.0 14.5219 . . . . 1 6.1767 . . 62 CGC 0007 08/03/94 1.0 14.5219 . . . . . . 1 9.5936 63 CGC 0007 09/20/94 1.0 14.5219 . . . . . . 1 11.1707 64 CGC 0008 . 0.0 6.8338 0 6.8338 0 6.8338 0 6.8338 0 6.8338 65 CHP 0001 02/03/94 1.0 22.4070 . . 1 11.5321 . . . . 66 CHP 0002 03/30/93 1.0 1.4785 . . . . 1 0.5585 . . 67 CHP 0003 . 0.0 0.1314 0 0.1314 0 0.1314 0 0.1314 0 0.1314 68 CHP 0004 12/26/94 1.0 20.9614 . . . . . . 1 20.7971 69 CHP 0005 05/11/94 1.0 19.0887 . . . . 1 11.4006 . . 70 CHP 0006 07/10/94 1.0 17.1831 . . . . 1 11.4664 . . 71 CHP 0007 . 0.0 17.1174 0 17.1174 0 17.1174 0 17.1174 0 17.1174 72 CHP 0008 . 0.0 9.3308 0 9.3308 0 9.3308 0 9.3308 0 9.3308 73 CHP 0012 05/17/94 1.0 13.5034 . . . . 1 6.0124 . . 74 CHP 0013 . 0.0 12.9777 0 12.9777 0 12.9777 0 12.9777 0 12.9777 75 CHP 0018 05/28/94 1.0 10.3821 . . . . 1 3.2526 . . 76 CHP 0019 04/22/94 1.0 10.5793 . . . . . . 1 2.2670 The SAS System 08:14 Friday, March 8, 1996 11

OBS INSTITUT PATNUM RETX INFDATE INFECT INT_FUP FUNGUS INT_FUNG PROTOZOA INT_PROT VIRUS INT_VIR BACTERIA INT_BACT

77 CHP 0020 . 0.0 10.0864 0 10.0864 0 10.0864 0 10.0864 0 10.0864 78 CHP 0022 09/01/94 1.0 5.8153 . . . . 1 1.8399 . . 79 CHP 0022 10/26/94 1.0 5.8153 . . . . 1 3.6469 . . 80 CHP 0032 . 0.0 4.9611 0 4.9611 0 4.9611 0 4.9611 0 4.9611 81 CHP 0033 09/01/94 1.0 3.9754 . . . . . . 1 0.0164 82 CMC 0003 . 0.0 2.6284 0 2.6284 0 2.6284 0 2.6284 0 2.6284 83 CMC 0004 . 0.0 0.2957 0 0.2957 0 0.2957 0 0.2957 0 0.2957 84 CMC 0005 05/31/94 1.0 16.8546 . . . . . . 1 9.8236 85 CMC 0006 . 0.0 15.2118 0 15.2118 0 15.2118 0 15.2118 0 15.2118 86 CMC 0007 . 0.0 11.6963 0 11.6963 0 11.6963 0 11.6963 0 11.6963 87 CMC 0008 . 0.0 11.5321 0 11.5321 0 11.5321 0 11.5321 0 11.5321 88 CMC 0009 . 0.0 8.6408 0 8.6408 0 8.6408 0 8.6408 0 8.6408 89 CMC 0010 A . 0.0 0.0986 0 0.0986 0 0.0986 0 0.0986 0 0.0986 90 CMC 0011 . 0.0 3.1212 0 3.1212 0 3.1212 0 3.1212 0 3.1212 91 CMD 0005 07/29/93 1.0 17.3802 . . . . . . 1 0.2957 92 CMD 0005 08/09/93 1.0 17.3802 . . . . . . 1 0.6571 93 CMD 0005 08/10/93 1.0 17.3802 . . . . 1 0.6900 . . 94 CMD 0005 08/14/93 1.0 17.3802 . . . . . . 1 0.8214 95 CMD 0005 08/16/93 1.0 17.3802 . . . . . . 1 0.8871 96 CMD 0005 08/20/93 1.0 17.3802 1 1.0185 . . . . . . 97 CMD 0005 08/23/93 1.0 17.3802 . . . . . . 1 1.1171 98 CMD 0005 08/30/93 1.0 17.3802 . . . . . . 1 1.3471 99 CMD 0005 09/28/93 1.0 17.3802 . . . . . . 1 2.2998 100 CMD 0005 10/27/93 1.0 17.3802 . . . . . . 1 3.2526

N = 100

options pagesize=80 linesize=132 notes obs=100;

libname buildinf '/mydir';

proc sort data=buildinf.phts(keep=institut patnum retx infdate infect int_fung int_prot int_vir int_bact fungus protozoa bacteria virus int_fup ) out=phts; by institut patnum retx infdate; proc print n; var institut patnum retx infdate infect int_fup fungus int_fung protozoa int_prot virus int_vir bacteria int_bact;

run;

DATA phtsf; SET phts; by institut patnum retx infdate; if infect = . then infect = 0; if first.patnum ne 1 and fungus =. then delete; if first.patnum = 1 and fungus =. then int_fung = int_fup; if first.patnum = 1 and fungus =. then fungus = 0;

data patient; set phtsf; by institut patnum infdate; if first.patnum = 1 and last.patnum=0 and fungus =0 then delete;

data patfung; set patient; by institut patnum infdate; if first.patnum = 1;

DATA phtsp; SET phts; by institut patnum retx infdate; if infect = . then infect = 0; if first.patnum ne 1 and protozoa=. then delete; if first.patnum = 1 and protozoa=. then int_prot = int_fup; if first.patnum = 1 and protozoa=. then protozoa = 0;

data patient; set phtsp; by institut patnum infdate; if first.patnum = 1 and last.patnum=0 and protozoa=0 then delete;

data patprot; set patient; by institut patnum infdate; if first.patnum = 1;

DATA phtsv; SET phts; by institut patnum retx infdate; if infect = . then infect = 0; if first.patnum ne 1 and virus =. then delete; if first.patnum = 1 and virus =. then int_vir = int_fup; if first.patnum = 1 and virus =. then virus = 0;

data patient; set phtsv; by institut patnum infdate; if first.patnum = 1 and last.patnum=0 and virus =0 then delete;

data patvirus; set patient; by institut patnum infdate; if first.patnum = 1;

DATA phtsb; SET phts; by institut patnum retx infdate; if infect = . then infect = 0; if first.patnum ne 1 and bacteria=. then delete; if first.patnum = 1 and bacteria=. then int_bact = int_fup; if first.patnum = 1 and bacteria=. then bacteria = 0;

data patient; set phtsb; by institut patnum infdate; if first.patnum = 1 and last.patnum=0 and bacteria=0 then delete;

data patbact; set patient; by institut patnum infdate; if first.patnum = 1; run;


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