SAS Procedures

Help using Base SAS procedures
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-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 764 views
  • 0 likes
  • 2 in conversation