BookmarkSubscribeRSS Feed
Barite | Level 11

Hello everyone,

Im trying to make a small change to the template of a statistical graphic plot. In the IIC plot from proc IRT I want the titles of each plot to be the variables labels instead of the variable name. 

I found the template that produce the plot, and also the statement that produce the title. 


In the code below, _ITEM0 will write the variable name in the title. How can I change that to the label of that variable?


proc template;
  source Stat.irt.Graphics.iteminfocurvepanel;
define statgraph Stat.IRT.Graphics.iteminfocurvepanel;
   notes "Plots of Item Curves ";
   dynamic _nItem _nRow _nCol _item0 _item1 _item2 _item3 _item4 _item5 _xmin _xmax _ymax _height _byline_ _bytitle_ _byfootnote_
   BeginGraph / designheight=_HEIGHT;
         if (_NITEM>0)
                  entry halign=center  _ITEM0 / textattrs=GRAPHLABELTEXT;
               Layout overlay / yaxisopts=(display=none) xaxisopts=(display=(line ticks tickvalues));
                  seriesplot x=TRAIT y=ITEMINFOI0;
Diamond | Level 26 RW9
Diamond | Level 26

Well, its not really to do with the template, as that just takes in a dynamic value.  Its more about you sgrender call.  So you could:

Call label in a datastep before into a macro variable and do it that way:

data _null_;
  set have (obs=1);
  call symput('lb',call label(yourvar));

proc sgrender...
  define _item0="&lb."...

(Note not tested!!).  Although I would really say that if you are using a label in title (or anywhere, then its probably better to put that as string data in your data, then calling the sgrender with a variable - this way its flexible to use whatever is in the variable, and you don't need macro.

Barite | Level 11

Thank you. Yes, I think you are right. That the sgrender procedure is called by the IRT procedure, not by me directly. 

Further, IRT doesnt output the dataset used for the iteminformation curves, so I can not even call the sgrender procedure myself.

Barite | Level 11

OK, I think I understood now. The problem was something different than what I original asked for. 

The iteminformation curves can be shown by proc irt. Proc IRT produce a dataset containing the values, and it then call proc sgrender with this dataset, and some dynamic value.


The dataset, which I actually can get out with a "ods output" statement, is very bad organized. It has only four variables, which then contains information for all items I have. So, if I have lets say 8 items, then the first 101 observations contains information values for the first 4 items, and the next 101 observations contains information for the last 4 items. And, no labels.


It now need some cumbersome, but simple work to get a nice graph out of this.

Diamond | Level 26 RW9
Diamond | Level 26

Sorry, never used proc irt, so do not know what the output from it is.  I would suggest starting by posting some example test data in the form of a datastep and show what you want out from it, so at least there is something to wor with.

Barite | Level 11

Im not able show share the real data. But with simulated data I can show you here what I mean:

*simulate a dataset;
data simulation;
  array q{8,4} _temporary_;
  array alpha{4} _temporary_;

  array item{8} 3;
  array probability{5} _temporary_;
  label item1="Anxiety" item2="Depression" item3="Hostility" item4="Guilt feelings" item5="Hallucinations" item6="Emotional withdrawal" item7="Grandiosity" item8="Disorientation";
  do i=1 to dim(q);
    do k=1 to dim(alpha);
	call sortn(of alpha(*));
    do k=1 to dim(alpha);

  do person=1 to 200;
	do i=1 to dim(item);
	do k=1 to 5;
	  if k=1 then probability[k]=cdf('logistic',alpha[1],l*p,1);
	  else if k<5 then  probability[k]=cdf('logistic',alpha[k],l*p,1)-cdf('logistic',alpha[k-1],l*p,1);
	  else if k=5 then probability[k]=1-cdf('logistic',alpha[k-1],l*p,1);
	output simulation;
  keep item:;

ods output iteminfocurve=iteminfocurve;
proc irt data=simulation plot=(iic) resfunc=graded;
  var item:;
*the iic curve is missing the labels.

*Using the iteminfocurve dataset, we can put in the labels ;
proc format;
  value item 1="Anxiety" 2="Depression" 3="Hostility" 4="Guilt feelings" 5="Hallucinations" 6="Emotional withdrawal" 7="Grandiosity" 8="Disorientation";
data iteminfocurve2;
  set iteminfocurve(in=a1 obs=101 keep=trait ItemInfoI0 rename=(ItemInfoI0=iteminfo) )
   iteminfocurve(in=a2 obs=101 keep=trait ItemInfoI1 rename=(ItemInfoI1=iteminfo))
    iteminfocurve(in=a3 obs=101 keep=trait ItemInfoI2 rename=(ItemInfoI2=iteminfo))
	 iteminfocurve(in=a4 obs=101 keep=trait ItemInfoI3 rename=(ItemInfoI3=iteminfo))
	  iteminfocurve(in=a5 firstobs=102 keep=trait ItemInfoI0 rename=(ItemInfoI0=iteminfo))
	   iteminfocurve(in=a6 firstobs=102 keep=trait ItemInfoI1 rename=(ItemInfoI1=iteminfo))
	    iteminfocurve(in=a7 firstobs=102 keep=trait ItemInfoI2 rename=(ItemInfoI2=iteminfo))
	    iteminfocurve(in=a8 firstobs=102 keep=trait ItemInfoI3 rename=(ItemInfoI3=iteminfo));
  format item item.;

proc sgpanel data=iteminfocurve2; panelby item; series x=trait y=iteminfo; run;




The early bird rate has been extended! Register by March 18 for just $695 - $100 off the standard rate.


Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 


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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1 like
  • 2 in conversation