SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
emmad511
Fluorite | Level 6
Hello! I have a problem related to proc sgplot. I have tried doing some code, but it didn't seem to work. Could someone help with this? Thanks in advance!
 
Here's the instructions of the problem: 
 
4. Use PROC SGPLOT to 
  a. Create a time series plot with smooth lines, where the time component (DATE) is the x-axis and the percent (StLouis) is the y-axis. 
    i. Add a blue line with line thickness equaled to 2. 
    ii.Add a legend label called ‘Economic Conditions Index for St. Louis, MO-IL (MSA)’. 
  b. Create a time series plot with smooth lines, where the time component (DATE) is the x-axis and the percent (RealGDP) is the y-axis.
    i. Add a red line with line thickness equaled to 2 
    ii. Add a legend label called ‘Real Gross Domestic Product’. 
 
Here's what I have so far:
proc import 
	out = StLouis 
    datafile = '/folders/myfolders/sasuser.v94/all_data/extdata/StLouisData.csv'
    dbms = CSV replace;
    getnames = YES;
run;
proc print data=StLouis;
run; 

proc sort data=StLouis;
  by Date StLouis;
run;

ods pdf style=analysis file="StLouis.pdf";
proc sgplot data=StLouis;
  loess x=Date y=StLouis / smooth nomarkers lineattrs=(color=blue thickness=2) legendlabel="Economic Conditons Index for St. Louis, MO-IL (MSA)";
run;

proc sort data=StLouis;
  by Date RealGDP;
run;

proc sgplot data=StLouis;
  loess x=Date y=RealGDP / smooth lineattrs=(color=red thickness=2) legendlabel="Real Gross Domestric Product";
run;
ods pdf close;
1 ACCEPTED SOLUTION

Accepted Solutions
emmad511
Fluorite | Level 6

It worked out! Thank you for your help:)

 

update: I didn't mean to select this reply as the correct answer... Since I don't know how to change it, I'll post the code I have right now.

 

Options papersize=(9in 3in);
ods pdf style=analysis file="/folders/myfolders/sasuser.v94/all_data/extdata/Overall Economy Activity.pdf";
proc sgplot data=StLouis;
  loess x=Date y=StLouis / smooth=10 lineattrs=(color=blue thickness=2) legendlabel="Economic Conditons Index for St. Louis, MO-IL (MSA)";
  loess x=Date y=RealGDP / smooth=5 lineattrs=(color=red thickness=2) legendlabel="Real Gross Domestric Product";;
  keylegend / location=outside position=bottomleft VALUEATTRS=(Size=8);
run;
ods pdf close;

 

View solution in original post

4 REPLIES 4
japelin
Rhodochrosite | Level 12

Specify an appropriate value for smooth.

smooth -> smooth=n

(Or you can remove smooth and sgplot will work.)

 

SGPLOT Procedure / LOESS Statement 

2021-04-09_13h38_06.png

emmad511
Fluorite | Level 6

It worked out! Thank you for your help:)

 

update: I didn't mean to select this reply as the correct answer... Since I don't know how to change it, I'll post the code I have right now.

 

Options papersize=(9in 3in);
ods pdf style=analysis file="/folders/myfolders/sasuser.v94/all_data/extdata/Overall Economy Activity.pdf";
proc sgplot data=StLouis;
  loess x=Date y=StLouis / smooth=10 lineattrs=(color=blue thickness=2) legendlabel="Economic Conditons Index for St. Louis, MO-IL (MSA)";
  loess x=Date y=RealGDP / smooth=5 lineattrs=(color=red thickness=2) legendlabel="Real Gross Domestric Product";;
  keylegend / location=outside position=bottomleft VALUEATTRS=(Size=8);
run;
ods pdf close;

 

ChrisNZ
Tourmaline | Level 20

Surely you are supposed to do your homework yourself?

emmad511
Fluorite | Level 6

Surely thanks for bumping tho^^

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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
  • 4 replies
  • 1176 views
  • 2 likes
  • 3 in conversation