Hello all! I am a new user to SAS and was trying to manipulate a dataset to produce tables with prevalence rates. I have several variables like disease status (1,0), age (binned into categories), location (various sites), and year (binned by calender year). I was trying to create a single variable that would represent the prevalence rate so I could easily produce 2x2 tables with prevalence rate by various other vars (year, age, location etc). In my data step I was trying to do this the following way: data prevalence; set work.import; length Hivstatus $ 10; if hivpos =1 then Hivstatus = "Positive"; if hivpos =0 then Hivstatus = "Negtive"; if hivpos =1 then Hivpositive = "HIV Positive"; if hivpos =0 then Hivnegative = "HIV Negative"; if hivpos in (0,1) then HIVtotal = "All Cases"; if hivpos = 1 then HIVcases = "HIV Positive Cases"; HIVprevelence = HIVcases/HIVtotal; It ends up producing a variable "HIVprevelence" where all the data are listed as "missing". Im not sure if there the code is incorrect or if I am thinking about doing this the wrong way. It very difficult to get prevalence rates with multiple variables using proc freq. Any help appreciated! data prevalence;
set work.import;
length Hivstatus $ 15;
if hivpos =1 then Hivstatus = "Positive";
if hivpos =0 then Hivstatus = "Negtive";
if hivpos =1 then Hivpositive = "HIV Positive";
if hivpos =0 then Hivnegative = "HIV Negative";
if hivpos in (0,1) then HIVtotal = "All Cases";
if hivpos = 1 then HIVcases = "HIV Positive Cases";
HIVprevelence = HIVcases/HIVtotal;
run;
... View more