@jozuleta wrote:
Sorry, I guess I do not know exactly how to change it in my code.
I changed it like this:
proc sql; create table JORGE.PRE_Table1 as select monotonic() as row_no, Put(year, 4.) as Year, count(distinct RIC) format=8.0 as RIC, count(distinct ANCODE) format=8.0 as ANCODE, count(distinct BROKERNAM) format=8.0 as BROKERNAM, count(*) format=8.0 as Obs, mean(TP2P) format=8.2 as mean_TP2P from JORGE.SAMP_ESTIMATOR group by year ; quit; proc sql; create table JORGE.Tabelle_1(drop=row_no) as select * from JORGE.PRE_Table1 union select monotonic()+10 as row_number, 'TOTAL' as year, sum(RIC) format=8.0 as RIC, sum(ANCODE) format=8.0 as ANCODE, sum(BROKERNAM) format=8.0 as BROKERNAM, sum(Obs) format=8.0 as Obs, . format=8.2 as mean_TP2P from JORGE.PRE_Table1 union select monotonic()+100 as row_number, 'MEAN' as year, mean(RIC) format=8.0 as RIC, mean(ANCODE) format=8.0 as ANCODE, mean(BROKERNAM) format=8.0 as BROKERNAM, mean(Obs) format=8.0 as Obs, mean(mean_TP2P) format=8.2 as mean_TP2P from JORGE.PRE_Table1 ; quit;
The means should be all the same as the mean of the Reference table: 0.2191538Conclusion: There is something wrong with the whole code 😞
Guys thank you very much. It worked.
@Reeza Yes, for the groups they should not be the same (as you said) BUT the OVERALL MEANS should be the same (as you said, too). But unfortunately they are not the same.
If a run a proc means for all the three tables the means are different as described below. See screenshot
Why is this the reason and how can I solve it? I can not report tables with different overall means 😄
First proc mean is from the Reference Sample, second is from the Table by countries, third is from the Table by years.
Thanks for helping!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.