* You perform a simple proc freq on some HIV data ( made up data here ) Table of HIV by WBC HIV WBC(White Blood Cell Count) Frequency‚LOW ‚HI ‚ Total ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ POS ‚ 31 ‚ 4 ‚ 35 ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ NEG ‚ 8 ‚ 24 ‚ 32 ƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒˆ Total 39 28 67 * but you would like a tabulation of patients in each cell. You need this for quality control: HIV WBCLow(Patients) WBCHi(Patients) ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ POS 001 004 005 011 014 066 070 126 129 015 018 019 022 024 025 026 043 048 053 060 073 076 089 104 106 118 122 123 132 133 146 169 175 181 187 NEG 211 247 256 258 314 194 218 222 227 231 331 365 366 253 257 259 261 264 267 269 270 277 285 286 303 307 309 311 315 320 324 338 =========== Solution: ===========; Data Xit_HivWbc ( Label="Exit HIV White Blood Cell Count made up data"); Label WBC="White Blood Cell Count"; Input Patient : $ HIV : $ WBC : $ @@; Datalines; 001 POS LOW 004 POS LOW 005 POS LOW 011 POS LOW 014 POS LOW 015 POS LOW 018 POS LOW 019 POS LOW 022 POS LOW 024 POS LOW 025 POS LOW 026 POS LOW 043 POS LOW 048 POS LOW 053 POS LOW 060 POS LOW 066 POS HI 070 POS HI 073 POS LOW 076 POS LOW 089 POS LOW 104 POS LOW 106 POS LOW 118 POS LOW 122 POS LOW 123 POS LOW 126 POS HI 129 POS HI 132 POS LOW 133 POS LOW 146 POS LOW 169 POS LOW 175 POS LOW 181 POS LOW 187 POS LOW 194 NEG HI 211 NEG LOW 218 NEG HI 222 NEG HI 227 NEG HI 231 NEG HI 247 NEG LOW 253 NEG HI 256 NEG LOW 257 NEG HI 258 NEG LOW 259 NEG HI 261 NEG HI 264 NEG HI 267 NEG HI 269 NEG HI 270 NEG HI 277 NEG HI 285 NEG HI 286 NEG HI 303 NEG HI 307 NEG HI 309 NEG HI 311 NEG HI 314 NEG LOW 315 NEG HI 320 NEG HI 324 NEG HI 331 NEG LOW 338 NEG HI 365 NEG LOW 366 NEG LOW ; Run; *===================================; * Count 2x2 Table; Proc Freq Data=Xit_HivWbc Order=Data ; Tables HIV * WBC / nocol norow nopct; Run; *===================================; * Patient 2x2 Table; Proc Sql noprint; Select Patient into :PosLow Separated by ' ' From Xit_HivWbc Where HIV='POS' and WBC='LOW'; Select Patient into :NegLow Separated by ' ' From Xit_HivWbc Where HIV='NEG' and WBC='LOW'; Select Patient into :PosHi Separated by ' ' From Xit_HivWbc Where HIV='POS' and WBC='HI' ; Select Patient into :NegHi Separated by ' ' From Xit_HivWbc Where HIV='NEG' and WBC='HI' ; quit; run; options ls=255 ps=50;run; Proc Report Data=Xit_HivWbc(Obs=2) /* Dummy Table need some table here */ Nowd Headline HeadSkip ; Cols Patient HIV WbcLow WbcHi ; define Patient / order noprint; define HIV / computed; define WbcLow / computed flow width=22; define WbcHi / computed flow width=22; compute HIV / char length=3; If Patient = '001' then HIV="POS"; Else HIV ="NEG"; endcomp; compute WbcHi / char length=200; If Patient = '001' then WbcHi ="&PosHi"; Else WbcHi ="&NegHi"; EndComp; compute WbcLow / char length=200; If Patient = '001' then WbcLow ="&PosLow"; Else WbcLow ="&NegLow"; EndComp; break after patient / skip; quit; run;