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 |
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.