🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 04-08-2021 09:20 PM
(1175 views)
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Specify an appropriate value for smooth.
smooth -> smooth=n
(Or you can remove smooth and sgplot will work.)
SGPLOT Procedure / LOESS Statement
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Surely you are supposed to do your homework yourself?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Surely thanks for bumping tho^^