BookmarkSubscribeRSS Feed
_Manhattan
Quartz | Level 8

Good afternoon,

 

I am trying to create an automatized report, which means I want to create a pdf where the structure of the general information stays the same while the content changes. As I am sure that no one will understand what I mean by that, here is an example of what the PDF could look like:

Jakobsen96_0-1655720946591.png

By general Information I am talking about "Title", "Some Information", "Some other Information" etc. By content I am talking about "Information on Title 1", "1" etc. As those of you that are familiar with statistics and/or item response theory may have guessed, the whole report is about giving specific information on items out of a test battery. As it is confidential data I am working with I will not be able to attach the data. But my code so far looks more or less like this:

Libname Skalold "J:\Learning SAS\Skalierungsbericht Tests";

run;

%Let A = SE71009D SE71017D SE71046A; 

data skalold.IRTTest;
	set skalold.skalalt;
	keep SE71009D SE71017D SE71046A;
	array one(*) &A;
	do i=1 to dim(one);
		if one(i) = 1 then one(i) = 1;
		else if one(i) in (2, 3, 4, 9) then one(i) = 0;
		else if one(i) = 6 then one(i) = .r;
		else one(i) = .;
	end;
	drop i;
	
run;

ods graphics on;

proc irt data=Skalold.IRTTest resfunc=rasch plots=tic itemfit itemstat;
run;

ods graphics off;

So far, I have only managed to get the proc IRT step to work correctly. Now: I would like to get the individual information of every item in my report, but without having to copy the information out of the proc irt step manually for every item. As you can see in my code, I include only 3 items here (e. g. SE71009D), but the actual data contains way more items. As far as I can tell in my short time of using SAS, there surely should exist an option of creating a PDF that automatically updates the content on every Item while remaining the general information.

 

To conclude:

I would need SAS to update the content for item 1 as you can see in the PDF example above (e. g. "Information on item 1", "1", "XXX") with content for item XY (e. g. "Information on Item 2", "2", "XXX2"). Furthermore, I have to update Pictures for every item (e. g. "Picture (.jpeg) of Item 1" --> usually a screenshot of the item). And all of that should be saved to a PDF (or LaTeX if that is somehow easier) which is generated by simply running the SAS code. In the end I would have about 100 pages (approximately 1-2 pages per Item) with the same general Information, but individual content for every Item.

 

I am aware that my first question in this forum surely has some flaws, so if you need any further information just let me know. Anyway, I am very grateful for any input on ways to achieve the wanted PDF document. There may be no best way of doing it, but my last week of research was not very helpful at all. So if you got any ideas, please feel free to share them.

 

Kind regards,

 

Jakob

 

5 REPLIES 5
ballardw
Super User

No example data so I am not going to attempt anything. However Proc ODSTEXT or PROC ODSLIST are two different procedures to allow you to provide "boiler plate" or conditional text similar to your
"Some information" bits for each record  in a data set.

 

However if you intend to interleave "Item 1" information then the graph, then "Item 2" then another graph you are in the realm of MACRO coding in SAS.

 

If you can't provide example data then use/modify one that SAS uses, such as in the documentation of the Proc IRT.

_Manhattan
Quartz | Level 8
Thank you ballardw, I will talk to my prof. and ask him about the data. Maybe I will be able to upload some of the data I am working with. Otherwise, I will use some of SAS provided data 🙂
_Manhattan
Quartz | Level 8

Alright, here is some example data that is more or less structured like the original one. The code looks quite similar:

 

Libname Skalold "J:\Learning SAS\Skalierungsbericht Tests";

run;

%Let A = VarOne VarTwo VarThree; 

data skalold.SASforumtest2;
	set skalold.sasforumtest;
	keep VarOne VarTwo VarThree;
	array one(*) &A;
	do i=1 to dim(one);
		if one(i) = 1 then one(i) = 1;
		else if one(i) in (2, 3, 4) then one(i) = 0;
		else if one(i) = 6 then one(i) = .r;
		else one(i) = .;
	end;
	drop i;
	
run;

ods graphics on;

proc irt data=Skalold.sasforumtest2 resfunc=rasch plots=tic itemfit itemstat;
run;

ods graphics off;

That should work as intended. I'd appreciate any more clues or tips, but for now I will try to get into macro coding 🙂

Reeza
Super User

Before automating you should figure out how to do it for one case then automate it.

 

So instead of manually extracting information, you'll need to capture it from the output, via ODS tables and format it into some structure that can be used for reporting. 

 

Here's some instructions and explanations on how to capture output that is shown.
https://blogs.sas.com/content/sastraining/2017/03/31/capturing-output-from-any-procedure-with-an-ods...

 

I'm not familiar with IRT so no idea which of the shown items come from the procedure and which are fixed. 

Once you have that structured, you'll need to turn it into a macro to create the report automatically for each group/category or whatever defines each report. That part is usually pretty straightforward once you have a working case. 

 

Here are some resources on macros but again, start on getting a fully worked version of your report automated and then work on getting it repeated. 

 

UCLA introductory tutorial on macro variables and macros
https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/

Tutorial on converting a working program to a macro
This method is pretty robust and helps prevent errors and makes it much easier to debug your code. Obviously biased, because I wrote it 🙂 https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md

Examples of common macro usage
https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Ap...

 

Spoiler

@_Manhattan wrote:

Good afternoon,

 

I am trying to create an automatized report, which means I want to create a pdf where the structure of the general information stays the same while the content changes. As I am sure that no one will understand what I mean by that, here is an example of what the PDF could look like:

Jakobsen96_0-1655720946591.png

By general Information I am talking about "Title", "Some Information", "Some other Information" etc. By content I am talking about "Information on Title 1", "1" etc. As those of you that are familiar with statistics and/or item response theory may have guessed, the whole report is about giving specific information on items out of a test battery. As it is confidential data I am working with I will not be able to attach the data. But my code so far looks more or less like this:

Libname Skalold "J:\Learning SAS\Skalierungsbericht Tests";

run;

%Let A = SE71009D SE71017D SE71046A; 

data skalold.IRTTest;
	set skalold.skalalt;
	keep SE71009D SE71017D SE71046A;
	array one(*) &A;
	do i=1 to dim(one);
		if one(i) = 1 then one(i) = 1;
		else if one(i) in (2, 3, 4, 9) then one(i) = 0;
		else if one(i) = 6 then one(i) = .r;
		else one(i) = .;
	end;
	drop i;
	
run;

ods graphics on;

proc irt data=Skalold.IRTTest resfunc=rasch plots=tic itemfit itemstat;
run;

ods graphics off;

So far, I have only managed to get the proc IRT step to work correctly. Now: I would like to get the individual information of every item in my report, but without having to copy the information out of the proc irt step manually for every item. As you can see in my code, I include only 3 items here (e. g. SE71009D), but the actual data contains way more items. As far as I can tell in my short time of using SAS, there surely should exist an option of creating a PDF that automatically updates the content on every Item while remaining the general information.

 

To conclude:

I would need SAS to update the content for item 1 as you can see in the PDF example above (e. g. "Information on item 1", "1", "XXX") with content for item XY (e. g. "Information on Item 2", "2", "XXX2"). Furthermore, I have to update Pictures for every item (e. g. "Picture (.jpeg) of Item 1" --> usually a screenshot of the item). And all of that should be saved to a PDF (or LaTeX if that is somehow easier) which is generated by simply running the SAS code. In the end I would have about 100 pages (approximately 1-2 pages per Item) with the same general Information, but individual content for every Item.

 

I am aware that my first question in this forum surely has some flaws, so if you need any further information just let me know. Anyway, I am very grateful for any input on ways to achieve the wanted PDF document. There may be no best way of doing it, but my last week of research was not very helpful at all. So if you got any ideas, please feel free to share them.

 

Kind regards,

 

Jakob

 


_Manhattan
Quartz | Level 8

Thank you Reeza, I wanted to get into macro coding anyway, but till now it was always easier to find a faster way without macros. Anyways, thanks for your help and I will definitely check on all information you provided!

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 673 views
  • 2 likes
  • 3 in conversation