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

I want a line with Pap on the x-axis and Avg on the y-axis. the value on x-axis and y-axis should be the same order as in the data. the value on the y-axis should be from 50000 to 35000 with 5000 apart. The area under the line needs to be filled.  Any suggestions or ideas will be greatly appreciated!

Avg             Pap

$19,053.90 50294
$19,155.55 5J383
$19,371.27 5N916
$20,208.01 5SS32
$20,248.28 50382
$20,283.07 5K426
$20,325.72 5L390
$20,556.82 50601
$20,950.14 5N559
$21,083.23 53173
$21,126.84 51591
$21,323.31 5J277
$21,463.89 5L276
$21,519.23 51395
$21,555.70 5K402
$21,685.32 50824
$21,744.93 55106
$21,757.55 53322
$21,963.55 5L289
$22,044.51 50254
$22,217.93 55519
$22,325.57 5L433
$22,475.74 5J617
$22,853.99 53851
$23,074.72 5L432
$23,162.03 51900
$23,233.84 5M579
$23,962.97 55710
$24,627.27 51490
$24,851.93 5L807
$25,165.05 5P007
$25,293.85 99294
$25,313.81 53003
$25,539.16 53253
$25,572.13 5L190
$26,342.46 53503
$26,569.69 5N202
$26,774.96 54562
$27,094.48 5I155
$27,655.79 5K012
$27,682.86 53618
$27,731.45 52297
$28,274.90 5K982
$30,011.96 5N847
$30,835.18 5H055

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

From @Jay54 SGPLOT with BAND works like a charm, set the lower bound to 0 if you want the area filled in. 

Thanks for posting sample data, preferably in a data step in the future, which is the first step in my code below. 

data have;
    informat value comma. cat $5.;
    format value dollar20.2;
    input value cat;
    start=0;
    cards;
$19,053.90 50294
$19,155.55 5J383
$19,371.27 5N916
$20,208.01 5SS32
$20,248.28 50382
$20,283.07 5K426
$20,325.72 5L390
$20,556.82 50601
$20,950.14 5N559
$21,083.23 53173
$21,126.84 51591
$21,323.31 5J277
$21,463.89 5L276
$21,519.23 51395
$21,555.70 5K402
$21,685.32 50824
$21,744.93 55106
$21,757.55 53322
$21,963.55 5L289
$22,044.51 50254
$22,217.93 55519
$22,325.57 5L433
$22,475.74 5J617
$22,853.99 53851
$23,074.72 5L432
$23,162.03 51900
$23,233.84 5M579
$23,962.97 55710
$24,627.27 51490
$24,851.93 5L807
$25,165.05 5P007
$25,293.85 99294
$25,313.81 53003
$25,539.16 53253
$25,572.13 5L190
$26,342.46 53503
$26,569.69 5N202
$26,774.96 54562
$27,094.48 5I155
$27,655.79 5K012
$27,682.86 53618
$27,731.45 52297
$28,274.90 5K982
$30,011.96 5N847
$30,835.18 5H055
;
run;

proc sgplot data=have;
    band x=cat lower=start upper=value;
    yaxis values=(0 to 35000 by 5000);
    label value='Avg Amount' cat='PAP';
run;

View solution in original post

9 REPLIES 9
Reeza
Super User

See the 2D area plot on this page:

 

http://robslink.com/SAS/democd7/aaaindex.htm

 

I like to start here when creating graphs, since it has both the code and image. One drawback is that it uses GPLOT procedures when SG Procs are more common these days, SGPLOT. 

Jay54
Meteorite | Level 14

With SGPLOT, you can try using the BAND plot, with constant value for the bottom edge.

Reeza
Super User

From @Jay54 SGPLOT with BAND works like a charm, set the lower bound to 0 if you want the area filled in. 

Thanks for posting sample data, preferably in a data step in the future, which is the first step in my code below. 

data have;
    informat value comma. cat $5.;
    format value dollar20.2;
    input value cat;
    start=0;
    cards;
$19,053.90 50294
$19,155.55 5J383
$19,371.27 5N916
$20,208.01 5SS32
$20,248.28 50382
$20,283.07 5K426
$20,325.72 5L390
$20,556.82 50601
$20,950.14 5N559
$21,083.23 53173
$21,126.84 51591
$21,323.31 5J277
$21,463.89 5L276
$21,519.23 51395
$21,555.70 5K402
$21,685.32 50824
$21,744.93 55106
$21,757.55 53322
$21,963.55 5L289
$22,044.51 50254
$22,217.93 55519
$22,325.57 5L433
$22,475.74 5J617
$22,853.99 53851
$23,074.72 5L432
$23,162.03 51900
$23,233.84 5M579
$23,962.97 55710
$24,627.27 51490
$24,851.93 5L807
$25,165.05 5P007
$25,293.85 99294
$25,313.81 53003
$25,539.16 53253
$25,572.13 5L190
$26,342.46 53503
$26,569.69 5N202
$26,774.96 54562
$27,094.48 5I155
$27,655.79 5K012
$27,682.86 53618
$27,731.45 52297
$28,274.90 5K982
$30,011.96 5N847
$30,835.18 5H055
;
run;

proc sgplot data=have;
    band x=cat lower=start upper=value;
    yaxis values=(0 to 35000 by 5000);
    label value='Avg Amount' cat='PAP';
run;
Jay54
Meteorite | Level 14

Cool.

 

If the x-axis is really discrete, maybe a VBARPARM would work better?  Not sure what "slope" means between to category values.

 

proc sgplot data=have;
vbarparm category=cat response=value / barwidth=1 fill nooutline;
yaxis values=(0 to 35000 by 5000);
xaxis valuesrotate=vertical valueattrs=(size=6) discreteorder=data;
label value='Avg Amount' cat='PAP';
run;

 

Reeza
Super User

It was sorted continuously so I'm assuming some ranking? I would suspect, your correct and either VBARPARM or HBARPARM would be a better graphing modality. I would suggest HBARPARM as it makes the categories more legible. 

zhuxiaoyan1
Quartz | Level 8
good suggestion. Another question. How to change the font and size of the labels? Thanks!
zhuxiaoyan1
Quartz | Level 8

Thanks very much for the help! I got the graph. But my xaxis is croweded with all the values of Pap. I want to get rid off it and just keep the label "PAP". How should I do that? Thank you again.

 

DanH_sas
SAS Super FREQ

On the XAXIS statement, add:  ddisplay=(noticks novalues)

zhuxiaoyan1
Quartz | Level 8
It works. Thank you very much!

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
  • 9 replies
  • 4105 views
  • 4 likes
  • 4 in conversation