BookmarkSubscribeRSS Feed
Peka
Calcite | Level 5

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;

1 REPLY 1
PaigeMiller
Diamond | Level 26

Since you didn't explain, let me ask why do you say "cannot merge the sets back onto the main set and room_name"?

 

Explain!!!

 

Show us your SASLOG.

 

Show us a portion of your data, following these instructions: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

--
Paige Miller

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 585 views
  • 0 likes
  • 2 in conversation