BookmarkSubscribeRSS Feed
vtd17
Calcite | Level 5
Hi,

I am creating an individual stick plot for each subject, and instead of having a legend want to label each stick by subject id.

I have a different symbol for each subj and different color based on gender. Unable to figure out a way to label the sticks with subject id. can anyone help. Thanks in advance.

data _null_ ;
set concent end=eof;
retain patcount 0;
by subjid;

if first.subjid then patcount+1;

if sex='M' then do;
call symput('sym'||trim(left(patcount)),'symbol'||trim(left(patcount)) || ' '|| 'c'='black'|| ' '||'v=none'||' '|| 'i=join'|| ' ' || 'line=1' || 'width=1' ||';');
end;

if sex='F' then do;
call symput('sym'||trim(left(patcount)),'symbol'||trim(left(patcount)) || ' '|| 'c'='red'|| ' '||'v=none'||' '|| 'i=join'|| ' ' || 'line=1' || 'width=1' ||';');
end;

if eof then call symput('total',patcount);
run;

%put &total. &sym1. ;


/*create a macro that goptions mlogic mprint symbolgenenerates all the symbol statements*/

%macro symbol ;
%do j=1 %to &total;
&&sym&j
%end;
%mend symbol ;

%symbol ;



goptions nodisplay;

proc gplot data =concent gout=work.mycat;
plot result * visit=subjid /vaxis=axis1 haxis=axis2 nolegend;

axis1 label=(a=90 'Result')
order=(0 to 100 by 10);

axis2 label=('Visit') minor=none;

run;
quit;
1 REPLY 1
GraphGuy
Meteorite | Level 14
I'm not really sure, without the data to try it, but ... I think you could use either pointlabel or annotate.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1 reply
  • 906 views
  • 0 likes
  • 2 in conversation