@Hello_there wrote:
Unfortunately that didn't work.
So, you still got duplicates? Or an error in the log (if so, please show the log)?
If i break it apart this code returns back the right number of rows (without the counts).proc sql; create table look as select * from (select distinct trt01an from adsl), (select distinct soc_term, pt_term from adae); quit;
I was wondering if it was possible to do a right join with the counts to that. But it looks like the below code doesn't work.
proc sql; create table want as select soc_term, pt_term, trt01an, count(distinct a.subject) as count from adae a natural right join select * from (select distinct trt01an from adsl), (select distinct soc_term, pt_term from adae) group by soc_term, pt_term, trt01an; quit;
To use the first query (creating dataset look) as a subquery in another query you must put it into parentheses: ... right join (select * from (...), (...)).
Your query has changed from your previous post, which used aebodsys and aedecod. Now that soc_term and pt_term come from both sides of the natural right join, you would need the "calculated" keyword before all three items in the GROUP BY clause or simply use the abbreviation
group by 1,2,3;
as discussed earlier in this thread.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.