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.

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