Hi,
I have two questions which I have listed below. Can anyone help me on it.
Let's say, I have a dataset named 'Sample' which is as follows:
Sample :
Patient_No Test1 Test2 Test3
101 20 30 70
102 22 32 55
103 30 50 88
104 50 29 63
105 45 60 72
1. I want to create a pdf for each single observation, which means I want to create 5 different Pdf files for 5 obs from above dataset.
2. Also, I want to name to those files automatically. Each of the files must have the name as per value from it's 'Patient_No' column. E.g. - pdf file for Patient_No - 101 must have the name as 'Patient 101', for Patient_No 102 it should be 'Patient 102' and so on.
Can anyone confirm me that is it possible to program the above requirement using sas? If yes, then could you please help me on it?
Many Thanks in Advance.
Regards,
Vikrant
Thank you very much Haikuo. It works perfectly. I have another doubt.
I have three datasets named A, B and C which are as follows.
Dataset A Dataset B Dataset C
PatientName Test1 Test2 Test3 PatientName Test4 Test5 Test6 PatientName Test4 Test5 Test6
Alex 10 20 30 Alex 50 60 65 Alex 63 65 70
Sachin 40 50 60 Sachin 30 45 55 Sachin 50 60 65
Mark 30 45 55 Mark 40 50 60 Mark 10 20 30
Ram 63 65 70 Ram 40 50 60 Ram 30 45 55
Now I want to export data of the one patient from all 3 datasets into separate pdf (in pdf information from each dataset should appear separate pdf pages). E.g. all the information from 3 datasets of patient let's say Alex should you exported into one pdf (separate page for each dataset) and so on.
Many thanks in advance for your help
Many methods could be used to do it, here is call execute:
data _null_;
set sashelp.class(obs=3) end=last;
if _n_ then call execute('ods pdf file=');
call execute('"c:\temp\name_'||strip(name)||'.pdf" ;
proc print data=sashelp.class;
where name="'||strip(name)||'";
run;
');
if last then call execute('ods pdf close;');
run;
I like this approach. A little mod on your code will output one obs per pdf without 'where' condition.
data _null_;
set sashelp.class(obs=4) end=last;
if _n_ then call execute('ods pdf file=');
call symputx('n',_n_);
call execute('"h:\temp\name_'||strip(name)||'.pdf" ;
proc print data=sashelp.class(firstobs=&n obs=&n);
/*where name="'||strip(name)||';*/
run;
');
if last then call execute('ods pdf close;');
run;
Thank you very much Haikuo. It works perfectly. I have another doubt.
I have three datasets named A, B and C which are as follows.
Dataset A Dataset B Dataset C
PatientName Test1 Test2 Test3 PatientName Test4 Test5 Test6 PatientName Test4 Test5 Test6
Alex 10 20 30 Alex 50 60 65 Alex 63 65 70
Sachin 40 50 60 Sachin 30 45 55 Sachin 50 60 65
Mark 30 45 55 Mark 40 50 60 Mark 10 20 30
Ram 63 65 70 Ram 40 50 60 Ram 30 45 55
Now I want to export data of the one patient from all 3 datasets into separate pdf (in pdf information from each dataset should appear separate pdf pages). E.g. all the information from 3 datasets of patient let's say Alex should you exported into one pdf (separate page for each dataset) and so on.
Many thanks in advance for your help
The output part can still be the same, only first merge/join the 3 tables by patientname, assume that they are 1:1 ratio,
proc sq;
create table want as
select * from a, b, c
where a.patientname=b.patientname and a.patientname=c.patientname
;
quit;
thank you for your help.
But I want to create a pdf for each patient where each record of the patient from each dataset will be created on the separate page. Please consider my previous example. The records the patient let's say 'Alex' is present in 3 datasets. So I want to create a Single Pdf for patient 'Alex' where the exported pdf consists the observations from each dataset into separate pages within it. Means obs for 'Alex' from Dataset A should on 1st page, obs from dataset B on 2nd page and so on.
Thank you very much in advance.
I see you have already posted here two weeks ago, with less details, I must have overlooked, my bad. So condsider the following:
proc sort data=sashelp.class(drop=height) out=no_height;
by name;
run;
proc sort data=sashelp.class(drop=weight) out=no_weight;
by name;
run;
proc sort data=sashelp.class(drop=age) out=no_age;
by name;
run;
data final;
set no: indsname=dsname;
by name;
source=dsname;
if _n_>6 then
stop;
run;
data _null_;
set final end=last;
by name;
if first.name then
call execute('ods pdf file='||'"h:\temp\name_'||strip(name)||'.pdf";' );
call execute('ods pdf startpage=now;
proc print data=final(firstobs='||_n_||' obs='||_n_||');
run;'
);
if last then
call execute('ods pdf close;');
run;
Please note, since your request evolved, so I opted to choose a different merge strategy, rather, it is more like a sorted 'stacking', in order to show the 'source' of your obs.
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.