SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Creating weighted variables

Reply
Frequent Learner
Posts: 1

Creating weighted variables

I'm having a problem that should be easy to solve, but my SAS experience is quite weak. My dataset have multiple records per case, with each record containing data for a single episode = number of days spent on a given hospital unit. I want to divide the number of days spent on each hospital unit with the total number of days spent on all hospital units. I have attached a simplified example of the data structure and added a column of what I want to add to the data.

 

Appeciate all suggestions,

 

Mats

Super Contributor
Posts: 490

Re: Creating weighted variables

proc sql ;
select *, days/SUM (days)  as weight
from have
group by id;
quit;
Ask a Question
Discussion stats
  • 1 reply
  • 252 views
  • 0 likes
  • 2 in conversation