I'm trying to create a new variable for my dataset that uses proportions from other variables. I created a variable for the mean level of compliance in each room (room_complianceMEAN) in a separate dataset but cannot merge the sets back onto the main set and room_name. I'm using SAS 9.4 I’m trying to: 1. total the number of observations where a certain dispenser is used for a room where dispensing_sensor_name = “sensor name” and room_name =“room name”; 2. create a variable that acts as the proportion of uses in that room to the total number of use in that room 3. add these variables to the dataset so they can be used along with others in a model use_proportion, room_rank, worker_type, floor, intervention, etc. PROC MEANS data = hh7; VAR compliant; CLASS room_name; OUTPUT OUT=room_complianceMEAN MEAN= /AUTONAME; run; proc print data = room_complianceMEAN; run; PROC freq data = hh7; where compliant =1; tables dispensing_sensor_name; by room_name; OUTPUT OUT=room_USEPROPORTION; run; proc print data =room_USEPROPORTION; run; proc freq data = hh7; where room_name="Room 7108-9"; tables dispensing_sensor_name*compliant /missing; OUTPUT OUT=room_USEPROPORTION; run;
... View more