BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Gil_
Quartz | Level 8
Here is what I'm using to create the chart it's in the result window

/* Define the line chart template */
proc template;
define statgraph linechart;
begingraph;
/* Create a dynamic variable for the year */
dynamic year;

/* Define the display attributes for each stock. Since
DISCRETEATTRMAP does not support the MARKERATTRS=
suboption SIZE=, the marker size is set separately. */
discreteattrmap name="company" / ignorecase=true ;
value "shoe" /
markerattrs=(color=blue symbol=trianglefilled)
lineattrs=(color=lightblue pattern=solid);
value "skirt" /
markerattrs=(color=red symbol=circlefilled)
lineattrs=(color=verylightred pattern=solid);
value "pants" /
markerattrs=(color=orange symbol=squarefilled)
lineattrs=(color=verylightorange pattern=solid);
enddiscreteattrmap ;

/* Associate the attribute map with input data column Stock and
assign the name STOCKATTRS to the named association */
discreteattrvar attrvar=companyattrs var=company attrmap="company" ;

entrytitle "company Index Performance in " year;
layout overlay /
/* Add a grid */
xaxisopts=(griddisplay=on gridattrs=(pattern=dot
color=lightgray))
yaxisopts=(griddisplay=on gridattrs=(pattern=dot
color=lightgray));
linechart category=date response=close / name="linechart"
/* Compute the mean */
stat=mean

/* Group by stock using the specified attributes */
group=companyattrs

/* Display the lines and markers */
display=(line markers)

/* Set the marker size */
markerattrs=(size=6)

/* Show vertex labels and specify their attributes */
vertexlabel=true
vertexlabelattrs=(size=7pt)
vertexlabelformat=dollar4.0;

/* Add a legend */
discretelegend "linechart";
endlayout;
endgraph;
end;
run;

/* Create a macro that generates a line chart for a specific year */
%macro genchart(year=);
/* Generate the chart */
proc sgrender data=companys template=linechart;
where year(date)=&year; /* Get the data for the specified year */
format date monname3.; /* Format the date as 3-letter month */
dynamic year="&year;"; /* Pass the year to the template */
run;
%mend genchart;

/* Generate a chart for 2001 */
%genchart(year=2020);
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

I would start with

 

ods excel file='c:\folder\path\myexcelfile.xlsx';

<code that generates the results I want in Excel>

ods excel close;

There are lots of options that go into things like naming tabs and such though.

 

By code that generates results I generally mean just the report or graphic output. Things like your template and macro definitions and all of the data manipulation are better done prior to the display part.

View solution in original post

1 REPLY 1
ballardw
Super User

I would start with

 

ods excel file='c:\folder\path\myexcelfile.xlsx';

<code that generates the results I want in Excel>

ods excel close;

There are lots of options that go into things like naming tabs and such though.

 

By code that generates results I generally mean just the report or graphic output. Things like your template and macro definitions and all of the data manipulation are better done prior to the display part.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 1 reply
  • 840 views
  • 0 likes
  • 2 in conversation