Create a template with all subjects and cycles.
data required;
input cycle $;
datalines;
C1
C2
C3
C4
C5
C6
C7
;
proc sql,
create table template as
select distinct a.subject, b.cycle
from have a, required b
;
quit;
Then use this in a MERGE to determine the missing rows.
data want;
merge
have (in=h)
template
;
by subject cycle;
if not h;
keep subject cycle;
run;
Untested; for tested code, supply example data in usable form (data step with datalines, posted in a code box).
data required;
input cycle $;
datalines;
C1
C2
C3
C4
C5
C6
C7
;
data have;
input subject $ cycle $;
cards;
Sub1 C1
Sub1 C2
Sub1 C5
Sub2 C1
Sub2 C2
Sub2 C3
Sub2 C7
;
proc sql;
create table temp as
select subject,
min(input(compress(cycle,,'kd'),best.)) as min,
max(input(compress(cycle,,'kd'),best.)) as max
from have
group by subject;
quit;
data temp2;
set temp;
length cycle $ 20;
do i=min to max;
cycle=cats('C',i);output;
end;
keep subject cycle;
run;
proc sql;
create table want as
select * from temp2
except
select * from have;
quit;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.