Hi,
I have a dataset with variables denoting the statuses for the observations as at a month end. The key variables are 'StatusAtMonthend' and 'DaysAtStatusAtMonthend' which are repeated for each of the month ends going back several years. I want to calculate mean and median for the 'DaysAtStatusAtMonth' variable for each of the statuses in the 'StatusAtMonthend' variable.
I created two arrays in a datastep holding all the 'StatusAtMonthEnd' in one array and the 'DaysAtStatusAtMonthend' in another. However, I do not know how to calculate the mean/median in the data step, I think it requires a proc means, but it will be inefficient to write a proc means for each of the month ends for several years.
data stats;
set statuses;
array TCs {*} Status2015_01-Status2015_12;
array DaysTC {*} DaysAtStatus2015_01-DaysAtStatus_12;
run;
I want the mean/median days spent in each of the statuses at each of the month ends.
Please can someone point me in the right direction?
Thanks.
(Enterprise Guide 7.1)
Transpose the dataset from wide to long format with proc transpose, then you can use proc means.
When executing a macro with call execute, use single quotes for the macro call, or the macro will be expanded before the data step (that contains the call execute) runs.
Hello,
you have missing || before DaysST(i) in the call execute syntax.
Anyway i don't think you will get the desired results with this aproach...
You miss a concatenation operator between the second comma and DaysST(i).
It would help to give a few example records and what the expected output should be.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.