Graphics Programming

Data visualization using SAS programming, including ODS Graphics and SAS/GRAPH. Charts, plots, maps, and more!
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
pakiprinsesse
Calcite | Level 5

I want to plot mean and confidence intervals in gplot. I have tried modifying a code found in the community (see below) for my data but it only produces the Means with a joined line and no error bars and I get the error message:

 

 

NOTE: ERROR DETECTED IN ANNOTATE= DATASET WORK.ANNO.

VARIABLE SHOWN IS NOT OF THE PROPER DATATYPE YC

NOTE: ERROR LIMIT REACHED IN ANNOTATE PROCESS. PROCESSING IS TERMINATED.

NOTE: PROCESSING TERMINATED BY INDIVIDUAL ERROR COUNT.

NOTE: 1 TOTAL ERRORS.

 

Could anyone please tell me how to solve the issue?

Thanks,

Anna

 

proc summary data=PAwPDAPFO;

by dage;

var CO;

output out=means (drop=_:) mean=mean lclm=lclm uclm=uclm;

run;

 

data anno;

length function color $8;

retain when 'a';

set means;

 

/*draw horisontal line from limit to limit*/

function='move'; yc=var; xsys='2'; ysys='2'; x=lclm; color='black'; output;

function='draw'; x=uclm; size=1; output;

 

/*draw tick line for lower*/

function='move'; xsys='2'; ysys='2'; yc=var; y=.; x=lclm; color='black'; output;

function='draw'; x=lclm; y=+1; ysys='9'; size=1; output;

function='draw'; x=lclm; y=-2; size=1; output;

 

/*draw tick line for upper*/

function='move'; xsys='2'; ysys='2'; yc=var; y=.; x=uclm; color='black'; output;

function='draw'; x=uclm; y=+1; ysys='9'; size=1; output;

function='draw'; x=uclm; y=-2; size=1; output;

run;

 

symbol1 value=dot height=1 color=black;

 

proc gplot data=means;

plot mean*dage/annotate=anno nolegend;

run; quit;

 

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

Try this instead. It's a lot less code 🙂

 

proc sgplot data=PAwPDAPFO noautolegend;
vline dage / response=CO stat=mean limitstat=clm markers;
run;

Hope this helps!

Dan

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

According to the error message:

 

VARIABLE SHOWN IS NOT OF THE PROPER DATATYPE YC

 

You have the wrong variable type for YC. It is expecting a character variable, and you have provided a numeric variable. But if you are trying to draw confidence intervals, you probably want to use variable Y and not YC.

--
Paige Miller
pakiprinsesse
Calcite | Level 5

Thank you. Changing the variable to character helped me a lot along the way!

 

PaigeMiller
Diamond | Level 26

@pakiprinsesse wrote:

Thank you. Changing the variable to character helped me a lot along the way!

 


Just in case there's any interest in the PROC GPLOT solution ... I didn't advise to change the variable to character. I advised that you use Y instead of YC, with a numeric variable.

--
Paige Miller
DanH_sas
SAS Super FREQ

Try this instead. It's a lot less code 🙂

 

proc sgplot data=PAwPDAPFO noautolegend;
vline dage / response=CO stat=mean limitstat=clm markers;
run;

Hope this helps!

Dan

pakiprinsesse
Calcite | Level 5

Thank you!.

That worked as well.

 

In the mean time I succeeded with plot and the following code:

 

procsortdata=PAwPDAPFO;

bydage;

run;

 

procsummarydata=PAwPDAPFO;

bydage;

varCO;

outputout=means (drop=_:) mean=meanlclm=lclmuclm=uclm;

run;

  

/*CONVERT DAGE FROM NUMERIC TO CHARACTER*/

 

datameansCO; setmeans;

char_dage=put(dage,$2.);

dropdage;

renamechar_dage=dage;

run;

 

/*GRAPH*/

 

dataanno;

lengthfunction color $8;

retain/*xsys ysys '2' */when 'a';

setmeansco;

 

/*draw VERTICAL line from limit to limit (=ERROR BARS)*/

function='move'; Xc=dage; xsys='2'; ysys='2'; Y=lclm; color='black'; output;

function='draw'; Y=uclm; size=1; output;

 

/*draw tick line for lower CONFIDENCE LIMIT*/

function='move'; xsys='2'; ysys='2'; Xc=dage; X=.; Y=lclm; color='black';output;

function='draw'; Y=lclm; X=+1; Xsys='9'; size=1;output;

function='draw'; Y=lclm; X=-2; size=1; output;

 

/*draw tick line for upper CONFIDENCE LIMIT*/

function='move'; xsys='2'; ysys='2'; Xc=dage; X=.; Y=uclm; color='black';output;

function='draw'; Y=uclm; X=+1; Xsys='9'; size=1;output;

function='draw'; Y=uclm; X=-2; size=1; output;

run;

 

/*SET AXIS AND SYMBOLS*/

symbol1value=dot height=1color=black;

axis1order=0to28by1;

axis2order=0.4to1.75by0.1;

 

/*PLOT*/

procgplotdata=meansco;

plotMEAN*DAGE/annotate=anno nolegendhaxis=axis1 vaxis=axis2;

run;quit;

 

/******************************************************************************************************/

/******************************************************************************************************/

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 5 replies
  • 7484 views
  • 0 likes
  • 3 in conversation