Hy,
I'm running this program:
proc sql;
select "TOTAL" as dest,
sum(Boarded) as Boarded format comma.
from sasuser.LAGUARDIA
outer union
select Dest,
sum(Boarded) as Boarded format comma.
from sasuser.LAGUARDIA
group by Dest;
quit;and SAS shows me this result:
I'd like to see the result of the first query (total boarded) just under the result of the second query (total boarded group by destination) without missing data. Something like this:
Is it possible? If yes, could you help me...thank a lot!
Have a nice day,
Daniele
Drop the OUTER and let UNION work as intended.
If you want to impose an order than spell it out.
proc sql;
select "TOTAL" as sex
, sum(weight) as weight format comma.
, 1 as ordervar
from sashelp.class
union
select sex
, sum(weight) as weight format comma.
, 2 as ordervar
from sashelp.class
group by sex
order by ordervar, sex
;
quit;
Well, with the above being said, if you still want to force OUTER UNION to overlay columns corresponding to the first select query, then
try OUTER UNION Corr
But please restrain such practices in a production code.
Drop the OUTER and let UNION work as intended.
If you want to impose an order than spell it out.
proc sql;
select "TOTAL" as sex
, sum(weight) as weight format comma.
, 1 as ordervar
from sashelp.class
union
select sex
, sum(weight) as weight format comma.
, 2 as ordervar
from sashelp.class
group by sex
order by ordervar, sex
;
quit;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.