BookmarkSubscribeRSS Feed
ak2011
Fluorite | Level 6
 
 


 

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;

 

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 data idnew1;
74 input id$ job idchem;
75 datalines;
 
NOTE: The data set WORK.IDNEW1 has 17 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.02 seconds
 
 
93 ;
94 run;
95
96 /* Cla-Exposure*/
97 data cla;
98 set idnew1;
99 if idchem=990005 then Cla_Exp=1; else Cla_Exp=0;
100 run;
 
NOTE: There were 17 observations read from the data set WORK.IDNEW1.
NOTE: The data set WORK.CLA has 17 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
 
 
101
102 proc print data=cla;
103 run;
 
NOTE: There were 17 observations read from the data set WORK.CLA.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.17 seconds
cpu time 0.18 seconds
 
 
104
105 /* Bio-Exposure*/
106 data bio;
107 set idnew1;
108 if idchem=9900021 then Bio_Exp=1; else Bio_Exp=0;
109 run;
 
NOTE: There were 17 observations read from the data set WORK.IDNEW1.
NOTE: The data set WORK.BIO has 17 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
 
 
110
111 proc print data=bio;
112 run;
 
NOTE: There were 17 observations read from the data set WORK.BIO.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.17 seconds
cpu time 0.17 seconds
 
 
113
114 /* Merging cla & bio files*/
115 data m1; merge cla bio;
116 run;
 
NOTE: There were 17 observations read from the data set WORK.CLA.
NOTE: There were 17 observations read from the data set WORK.BIO.
NOTE: The data set WORK.M1 has 17 observations and 5 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.02 seconds
 
 
117
118 proc print data=m1;
119 Title"Merged Cla & Bio exposures";
120 run;
 
NOTE: There were 17 observations read from the data set WORK.M1.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.18 seconds
cpu time 0.18 seconds
 
 
121
122
123
124 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
136
 

 Obs id job idchem Cla_Exp1234567891011121314151617

os119900051
os1199000210
os112117000
os122117000
os1299000210
os122107010
os129900051
os212107010
os219900051
os2299000210
os232107010
os239900051
os332107010
os312117000
os412107010
os419900051
os412117000

 Obs id job idchem Bio_Exp1234567891011121314151617

os119900050
os1199000211
os112117000
os122117000
os1299000211
os122107010
os129900050
os212107010
os219900050
os2299000211
os232107010
os239900050
os332107010
os312117000
os412107010
os419900050
os412117000

Merged Cla & Bio exposures

 Obs id job idchem Cla_Exp Bio_Exp1234567891011121314151617

os1199000510
os11990002101
os1121170000
os1221170000
os12990002101
os1221070100
os1299000510
os2121070100
os2199000510
os22990002101
os2321070100
os2399000510
os3321070100
os3121170000
os4121070100
os4199000510
os4121170000

 

 

1 REPLY 1
ak2011
Fluorite | Level 6
Please ignore this message. Is difficult to read the output. I will resend. Thanks.
ak

SAS Innovate 2025: Call for Content

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!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 324 views
  • 0 likes
  • 1 in conversation