BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
unnati
Obsidian | Level 7

Hello,

Can someone able to help to figure out how to add data point value in graph but not on X-axis. 

NOTE: I have to do this graph just for one subject. so all record in dataset LL is for one subject only.

I Have attached my code and output here.

As in graph, I am trying to add my data point (green triangle) inside the graph but, i don't want its value to  display on X-axis(which is Cycle 6 Day 11). I want that value just to display in between cycle 6 day 1 and cycle 7 day1.

 

data ll;
set lb_cm;
by subjid astdt ;
lag_adt=lag(astdt);
lag_visn=lag(avisitn);
lag_vis=lag(avisit);
if first.subjid then do; lag_adt= . ; end;
form

at lag_adt date9. ;
if astdt > lag_adt and avisitn eq . then do;
dys=astdt-lag_adt;
avisitn=sum(lag_visn,0.5);
avisit_1=substr(lag_vis,1,8)||" Day "||strip(put(dys,8.));
acyclec=substr(lag_vis,1,8);
acycle=(scan(lag_vis,2,' '))*1;
end;
if astdt_ ne '' then do; aval2=0.05; end;
if avisit='Screening' then do; aval2=.; end;
if avisit_1 eq '' then do; avisit_1=avisit; end;
run;
proc sgplot data=ll noautolegend cycleattrs;
styleattrs datacontrastcolors=(red green);
series x=avisit_1 y=aval / DATALABEL=chg MARKEROUTLINEATTRS=acyclec curvelabelattrs=(size=10)
group=trtp lineattrs=(thickness=3);

scatter y=aval2 x=avisit_1 / group=trtp markerattrs=(color=green symbol=triangle size=12);
yaxis display=all;
run;

IMAGE 1

unnati_0-1608249589939.png

unnati_1-1608249904856.png

 

I have also tried y=avisit but in that case i am able to populated data point in graph and instead of four it only populate three (i.e. cycle 3 day 1 , cycle 6 day 1 , cycle 8 day 15). 

 

Any help will appriciated.

 

Thank you.

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

If there is a relationship between the "analysis value" and "avisit_1", you might be able to assign the scatter plot to the X2 axis by using the X2AXIS option on the SCATTER statement. Then, you can turn off the display of the X2 axis by adding:

 

x2axis display=none;

 

Hope this helps!

Dan

View solution in original post

8 REPLIES 8
ballardw
Super User

The XAXIS statement is what you would supply to control what goes on the axis with a Values= <list> or rule.

Your current axis is awful busy and could use some pruning in my eye. Just make sure that the values don't include the value you don't like.

unnati
Obsidian | Level 7

Hello,

Can someone able to help to figure out how to add data point value in graph but not on X-axis. 

NOTE: I have to do this graph just for one subject. so all record in dataset LL is for one subject only.

I Have attached my code and output here.

As in graph, I am trying to add my data point (green triangle) inside the graph but, i don't want its value to  display on X-axis(which is Cycle 6 Day 11). I want that value just to display in between cycle 6 day 1 and cycle 7 day1.

data ll;
set lb_cm;
by subjid astdt ;
lag_adt=lag(astdt);
lag_visn=lag(avisitn);
lag_vis=lag(avisit);
if first.subjid then do; lag_adt= . ; end;
format lag_adt date9. ;
if astdt > lag_adt and avisitn eq . then do;
   dys=astdt-lag_adt;
   avisitn=sum(lag_visn,0.5);
   avisit_1=substr(lag_vis,1,8)||" Day "||strip(put(dys,8.));
   acyclec=substr(lag_vis,1,8);
   acycle=(scan(lag_vis,2,' '))*1;
end;
if astdt_ ne '' then do; aval2=0.05; end;
if avisit='Screening' then do; aval2=.; end;
if avisit_1 eq '' then do; avisit_1=avisit; end;
run;


proc sgplot data=ll noautolegend cycleattrs;
   styleattrs datacontrastcolors=(red green);
   series x=avisit y=aval / DATALABEL=chg   MARKEROUTLINEATTRS=acyclec  curvelabelattrs=(size=10)
                           group=trtp  lineattrs=(thickness=3);

scatter y=aval2 x=avisit / group=trtp  markerattrs=(color=green symbol=triangle size=12);
   yaxis display=all;
run;

I have also tried y=avisit but in that case i am able to populated data point in graph and instead of four it only populate three (i.e. cycle 3 day 1 , cycle 6 day 1 , cycle 8 day 15). 

Any help will be appreciated.sgplot.PNG

 

Thank you.

 

DanH_sas
SAS Super FREQ

If there is a relationship between the "analysis value" and "avisit_1", you might be able to assign the scatter plot to the X2 axis by using the X2AXIS option on the SCATTER statement. Then, you can turn off the display of the X2 axis by adding:

 

x2axis display=none;

 

Hope this helps!

Dan

unnati
Obsidian | Level 7

Thank you so much. It worked like magic for me. 

I really apricate your help.

 

Thank you once again !! 

unnati
Obsidian | Level 7

do you by chance know similar option for PROC SG panel.

DanH_sas
SAS Super FREQ

Unfortunately, not at this time.

DanH_sas
SAS Super FREQ

Since we currently do not support secondary axes in SGPANEL, you can use Proc SGPLOT with BY-group variable(s) and use ODS LAYOUT to lay them out in a grid. Proc SGplot has options to create uniform groups and axes across BY-groups.

unnati
Obsidian | Level 7

I am able to resolve my issue  by using PROC SGPLOT . Do you know if i want to apply same thing X2axis on PROC template then what is the option ?

 

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