Data visualization with SAS programming

I am trying to reproduce a graph with 4 variables and ingraph labeling

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

I am trying to reproduce a graph with 4 variables and ingraph labeling

I am trying to reproduce this graph but to make proportion with pain the y axis and those with ulcer the x axis.

I have tried

proc sgplot data=ulcer;

      series x=Proportion_with_ulcer y=proportion_with_pain / group=dose break /**lineattrs=(pattern1= solid pattern2=dot pattern3=dashdashdot pattern4=shortdash color=black )"**/;
pattern1  value= dose color=blue;
pattern2 value=dose color=red;
pattern3  value=dose color=pink;
pattern4  value=dose color=green;
            xaxis label='Proportion of Patients with Duodenal Ulcers' values=(0 to 1 by 0.2);

      yaxis grid label='Proportion of Patients with Daytime UGI Pain' values=(0 to 1 by 0.2);

portion of Patients with Daytime UGI Pain' values=(0 to 1 by 0.2);
       
run;

 it is not giving me what I want.

Please I need help urgently.

 

Thank you


quit;


Accepted Solutions
Solution
‎09-07-2017 07:18 AM
Frequent Contributor
Posts: 83

Re: I am trying to reproduce a graph with 4 variables and ingraph labeling

 

proc format;
  value dose 
      0 ='   0 mg hs'
    400 =' 400 mg hs'
    800 =' 800 mg hs'
   1600 ='1600 mg hs'
       ;
run;

proc sgplot data=ulcer;
  series x=proportion_with_pain y=proportion_with_ulcer / group=dose datalabel=week datalabelattrs=(size=10 weight=bold);
  styleattrs datalinepatterns=(solid shortdash mediumdash longdash);
  refline 0 0.2 0.4 0.6 0.8 1 / axis=y;
  xaxis min=0 label='Proportion of patients with Duodenal Ulcers';
  yaxis min=0 label='Proportion of Patients with Daytime UGI pain';
  format dose dose. ;
  keylegend / title='' down=2;
  inset '1, 2, 4 weeks of follow-up' / textattrs=(size=12 weight=bold) position=right;
run;

Series plot of proportion with ulcer by proportion with pain by doseSeries plot of proportion with ulcer by proportion with pain by dose

View solution in original post


All Replies
SAS Super FREQ
Posts: 196

Re: I am trying to reproduce a graph with 4 variables and ingraph labeling

You should look at the documentation for sgplot.  Also search for "basic ods graphics examples" book. Pattern statements are sas/graph and are ignored in ods graphics.

Occasional Contributor
Posts: 9

Re: I am trying to reproduce a graph with 4 variables and ingraph labeling

Thank you so much for your prompt response. I did as you suggested but I
still could not get the desired result.

The following are my data and variable.

data Ulcer;
input week dose Proportion_with_ulcer proportion_with_pain @@;
cards;
0 0 1 0.83
0 400 1 1
0 800 1 0.82
0 1600 1 0.85
1 0 0.81 0.79
1 400 0.82 0.80
1 800 0.84 0.70
1 1600 0.79 0.70
2 0 0.71 0.71
2 400 0.63 0.56
2 800 0.62 0.40
2 1600 0.51 0.35
4 0 0.59 0.60
4 400 0.38 0.50
4 800 0.28 0.38
4 1600 0.26 0.30
;
run;

I would appreciate it if you could write the SAS code.

Thank you.

Uche
Solution
‎09-07-2017 07:18 AM
Frequent Contributor
Posts: 83

Re: I am trying to reproduce a graph with 4 variables and ingraph labeling

 

proc format;
  value dose 
      0 ='   0 mg hs'
    400 =' 400 mg hs'
    800 =' 800 mg hs'
   1600 ='1600 mg hs'
       ;
run;

proc sgplot data=ulcer;
  series x=proportion_with_pain y=proportion_with_ulcer / group=dose datalabel=week datalabelattrs=(size=10 weight=bold);
  styleattrs datalinepatterns=(solid shortdash mediumdash longdash);
  refline 0 0.2 0.4 0.6 0.8 1 / axis=y;
  xaxis min=0 label='Proportion of patients with Duodenal Ulcers';
  yaxis min=0 label='Proportion of Patients with Daytime UGI pain';
  format dose dose. ;
  keylegend / title='' down=2;
  inset '1, 2, 4 weeks of follow-up' / textattrs=(size=12 weight=bold) position=right;
run;

Series plot of proportion with ulcer by proportion with pain by doseSeries plot of proportion with ulcer by proportion with pain by dose

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 154 views
  • 1 like
  • 3 in conversation