Dear community,
I am trying to extract single plots from my proc irt output as .png files. Best case scenario would be to save the plots under the same name as the variable names in a folder on my computer (so that there is a folder with the png files and with the varnames (var1 var2 var3) --> see example screenshot). I attached some example code and data to generate the wanted plots. Does anyone know how to do this? It seems to be quite simple, but I did not manage to find a solution yet.
Kind regards,
Jakob
proc import datafile="J:/Learning SAS/SmallIRT.xls"
out=SIRT
dbms=xls
replace;
run;
ods graphics on;
proc irt data=SIRT resfunc=rasch plots=icc(unpack);
run;
ods graphics off;
Not sure if there's an easier method, but if you pipe the output to an HTML file it will generate the PNG that the HTML file links to in a specified folder.
Something like this (tested) - images are in the GPATH specified folder:
ods html body='/home/fkhurshed/Demo1/example.html' gpath='/home/fkhurshed/Demo1/Reports/';
ods graphics on;
proc irt data=IrtUni link=probit resfunc=graded plots=icc(unpack);
var item1-item8;
model item1-item4/resfunc=twop, item5-item8/resfunc=graded;
run;
ods html close;
Not sure if there's an easier method, but if you pipe the output to an HTML file it will generate the PNG that the HTML file links to in a specified folder.
Something like this (tested) - images are in the GPATH specified folder:
ods html body='/home/fkhurshed/Demo1/example.html' gpath='/home/fkhurshed/Demo1/Reports/';
ods graphics on;
proc irt data=IrtUni link=probit resfunc=graded plots=icc(unpack);
var item1-item8;
model item1-item4/resfunc=twop, item5-item8/resfunc=graded;
run;
ods html close;
That worked just perfectly even though the .png files have not the same names as the variable names. But that will not be a big deal to fix. Thank you so much Reeza!
Hello @_Manhattan,
@_Manhattan wrote:
That worked just perfectly even though the .png files have not the same names as the variable names. But that will not be a big deal to fix.
Exactly. If needed, the renaming could be automated based on the HTML file, as it contains lines starting like
<img alt="var1" src="/home/fkhurshed/Demo1/Reports/ItemCharCurve1.png"
i.e., providing the relevant information: variable name and full path of the corresponding PNG file. This information could be retrieved in a DATA step and used, e.g., in an X statement to submit a rename command to the operating system.
I'm surprised that there doesn't seem to be an easier way to achieve your goal because naming the PNG files after the analysis variables seems quite natural, not only in PROC IRT, but in virtually all other statistical procedures producing ODS graphics as well. Yet, as far as I see, SAS currently offers only limited naming options:
ods listing gpath='c:\temp\a\' style=htmlblue;
ods graphics on;
proc logistic data=sashelp.class plots=all;
model sex=weight height;
run;
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.