PROC SQL;
CREATE TABLE SL_1 AS
SELECT distinct A,AEC,'Patients ' AS VARIABLE, 1 AS GRP, COUNT(DISTINCT SUBJID) AS CNT
FROM A(WHERE=(FL='Y')) GROUP BY AEC
UNION ALL
SELECT distinct A,AEC,'Patients 2' AS VARIABLE, 2 AS GRP, COUNT(DISTINCT SUBJID) AS CNT
FROM A(WHERE=(FL='Y' AND FFL='N')) GROUP BY AEC
;quit;
How to write above code in Data step
In general you wouldn't combine those types of calculations with the step that combines the datasets into one data step.
To combine two datasets (aka UNION) just use the SET statement.
data want;
set have1 have2;
run;
What if I have three tables that want to union?
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.