I would greatly appreciate if someone helps me with the code to count the number of id_job
combinations for the merged dataset below: I have a total of 17 obs with 8 id_jobs: os1-1,os1-1 and os1-1
is 1 id-job combination;os1-2,os1-2,os1-2,os1-2 and os1-2 is another id-job combination,etc
for a total of 8 id-job combinations. For cla_expo & bio-exp, 0=unexposed and 1=exposed.
My task is to count the number of id-job exposed for cla and bio: For cla(idchem=99005),bio(idchem=990021):
For cla: number of id_job exposed is 5/8=62.5%, bio:3/8=37.5%
I tried proc freq idchem(not shown) but it didn't give me the right percentages.
Could someone help me with the SAS code to compute the percent id_job exposed for cla and bio,please
Also for the id exposed : For cla(idchem=990005), % id exposed is 3/4 = 75%
Thanks very much.
data idnew1;
input id$ job idchem;
datalines;
os1 1 990005
os1 1 9900021
os1 1 211700
os1 2 211700
os1 2 9900021
os1 2 210701
os1 2 990005
os2 1 210701
os2 1 990005
os2 2 9900021
os2 3 210701
os2 3 990005
os3 3 210701
os3 1 211700
os4 1 210701
os4 1 990005
os4 1 211700
;
run;
Obs id job idchem Cla_Exp1234567891011121314151617
os1 | 1 | 990005 | 1 |
os1 | 1 | 9900021 | 0 |
os1 | 1 | 211700 | 0 |
os1 | 2 | 211700 | 0 |
os1 | 2 | 9900021 | 0 |
os1 | 2 | 210701 | 0 |
os1 | 2 | 990005 | 1 |
os2 | 1 | 210701 | 0 |
os2 | 1 | 990005 | 1 |
os2 | 2 | 9900021 | 0 |
os2 | 3 | 210701 | 0 |
os2 | 3 | 990005 | 1 |
os3 | 3 | 210701 | 0 |
os3 | 1 | 211700 | 0 |
os4 | 1 | 210701 | 0 |
os4 | 1 | 990005 | 1 |
os4 | 1 | 211700 | 0 |
Obs id job idchem Bio_Exp1234567891011121314151617
os1 | 1 | 990005 | 0 |
os1 | 1 | 9900021 | 1 |
os1 | 1 | 211700 | 0 |
os1 | 2 | 211700 | 0 |
os1 | 2 | 9900021 | 1 |
os1 | 2 | 210701 | 0 |
os1 | 2 | 990005 | 0 |
os2 | 1 | 210701 | 0 |
os2 | 1 | 990005 | 0 |
os2 | 2 | 9900021 | 1 |
os2 | 3 | 210701 | 0 |
os2 | 3 | 990005 | 0 |
os3 | 3 | 210701 | 0 |
os3 | 1 | 211700 | 0 |
os4 | 1 | 210701 | 0 |
os4 | 1 | 990005 | 0 |
os4 | 1 | 211700 | 0 |
Merged Cla & Bio exposures
Obs id job idchem Cla_Exp Bio_Exp1234567891011121314151617
os1 | 1 | 990005 | 1 | 0 |
os1 | 1 | 9900021 | 0 | 1 |
os1 | 1 | 211700 | 0 | 0 |
os1 | 2 | 211700 | 0 | 0 |
os1 | 2 | 9900021 | 0 | 1 |
os1 | 2 | 210701 | 0 | 0 |
os1 | 2 | 990005 | 1 | 0 |
os2 | 1 | 210701 | 0 | 0 |
os2 | 1 | 990005 | 1 | 0 |
os2 | 2 | 9900021 | 0 | 1 |
os2 | 3 | 210701 | 0 | 0 |
os2 | 3 | 990005 | 1 | 0 |
os3 | 3 | 210701 | 0 | 0 |
os3 | 1 | 211700 | 0 | 0 |
os4 | 1 | 210701 | 0 | 0 |
os4 | 1 | 990005 | 1 | 0 |
os4 | 1 | 211700 | 0 | 0 |
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.