BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
_Manhattan
Quartz | Level 8

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;

example screenshots.JPG

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;

View solution in original post

4 REPLIES 4
Reeza
Super User

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;
_Manhattan
Quartz | Level 8

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!

FreelanceReinh
Jade | Level 19

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:

  1. A "base image file name" can be specified in the IMAGENAME= option of the ODS GRAPHICS statement and this name would be suffixed automatically with an "index counter" (whose start value can be defined in the RESET= option). See section Specifying and Resetting the Image Name of the documentation. This might work for your var1, var2, var3, but not for arbitrary variable names.
  2. Only since SAS 9.4M5 there is an additional option: using BY-variable names and values in the image file name (see Substituting BY Line Values in the Image Name). But this doesn't apply to your PROC IRT step, which doesn't contain a BY statement.
Ksharp
Super User
ods listing gpath='c:\temp\a\'  style=htmlblue;
ods graphics on;
proc logistic data=sashelp.class plots=all;
model sex=weight height;
run;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1280 views
  • 2 likes
  • 4 in conversation