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

Hello!

I've sorted my data and created a sorted output data set ("SORT_MARKT"). I'm attempting to use that sorted data set to plot my data and show an ascending trend line, but once the data is plotted, it's displayed as if no sort was ever applied. I'm not sure what exactly is causing this to display this way.

 

My code:

 

PROC SORT DATA = MARKETING OUT=SORT_MARKT ;
BY sales  ;
RUN;

goptions reset=all border;
symbol value=dot interpol=sms line=1 width=2 ;
proc gplot data=SORT_MARKT ;
    plot sales*case_number /  haxis = 1 to 21 by 1
                              vaxis = 10000 to 23000 by 1000
                              vref = 13000 17000 20000    ;
run;
quit;

 

The attached picture shows the sorted data set and the proc gplot output. What am I missing?

sort.JPG

 

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

PROC GPLOT does not support data order, unless you use one of the "client" devices (actximg, activex, javaimg, java). If you want to try that approach, you will also need to use the DATAORDER option on the PLOT statment. However, I would recommend that you use SGPLOT instead to create this plot:

 

proc sgplot data=SORT_MARKT;
   xaxis type=discrete discreteorder=data;
   yaxis values=(10000 to 23000 by 1000);
   series x=sales y=case_number / markers smoothconnect
             markerattrs=(symbol=circlefilled) lineattrs=(thickness=2);
   refline 13000 17000 20000 / axis=x;
run;
            

Hope this helps!

Dan

View solution in original post

2 REPLIES 2
DanH_sas
SAS Super FREQ

PROC GPLOT does not support data order, unless you use one of the "client" devices (actximg, activex, javaimg, java). If you want to try that approach, you will also need to use the DATAORDER option on the PLOT statment. However, I would recommend that you use SGPLOT instead to create this plot:

 

proc sgplot data=SORT_MARKT;
   xaxis type=discrete discreteorder=data;
   yaxis values=(10000 to 23000 by 1000);
   series x=sales y=case_number / markers smoothconnect
             markerattrs=(symbol=circlefilled) lineattrs=(thickness=2);
   refline 13000 17000 20000 / axis=x;
run;
            

Hope this helps!

Dan

deltron
Fluorite | Level 6

Thanks, Dan. I finally saw what you meant about the PROC GPLOT route and opted to go with SGPLOT. Made one minor tweak to the Series statement.

sort2.JPG

Thank you for your time,

Rob

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
  • 2 replies
  • 839 views
  • 0 likes
  • 2 in conversation