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

Creating weighted variables

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,



Super Contributor
Posts: 490

Re: Creating weighted variables

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