Perhaps you need a step to determine a new grouping variable (or variables), add that to the data and use that new variable for By group processing?
Thanks Grand Advisor. I thought of it, and in fact, made sense to say something like "No AEs for this Subject" and create the dummy record. But it seemed to be more tedious and cumbersome than I wanted, and with Cynthia's reference and a correspondence with Rick Wicklin from SAS and his thread, it got me where I needed to be. So I arrived at the solution.
Thanks
Dan
Thanks Cynthia. That was a big help, although not the ultimate solution. But I did take that, and took advantage of ods output properties from PROC DOCUMENT to associate the path with the subject. Moved things around, and here's a working prototype.
Of course, this will need be generalized to replace "Print" with the actual proc, etc, but it's a great start. And it got what I wanted - so thanks again:
data demog;
input usubjid @@;
age = 70;
cards;
1 2 3 4 5
;
run;
data ae;
input usubjid evt $ @@;
cards;
3 AE1 3 AE2 3 AE3
;
run;
data cm;
input usubjid evt $ @@;
cards;
2 CM1 2 CM2 2 CM3
;
run;
ods document name=work.forsuperfreq(write);
proc print data=demog;
by usubjid;
run;
proc print data=ae;
by usubjid;
run;
proc print data=cm;
by usubjid;
run;
ods document close;
ods trace off;
ods output properties=props;
proc document name=work.forsuperfreq(update);
list / levels=all bygroups; /* add column for each BY group var */
run;
quit;
proc sql noprint;
select distinct path, cats("\Subject",usubjid)
into :from1-:from7, :to1-:to7
from props;
quit;
%put &from1 &from2 &to1 &to2;
options symbolgen mprint mlogic;
proc document name=work.forsuperfreq(update);
dir ^^;
%macro createsubdirs;
%do j=1 %to 5;
make \Subject&j;
run;
%end;
%mend;
%createsubdirs;
list /levels=all;
run;
dir ^^;
%macro movefolders;
%do k=1 %to 7;
move &&from&k to ^&&to&k.\Print ;
run;
%end;
%mend;
%movefolders;
list /levels=all;
ods pdf file = 'm:\procdocumentsandbox\filehelp.pdf';
dir ^^;
replay /;
run;
ods pdf close;
run;
quit;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.