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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 596 views
  • 0 likes
  • 2 in conversation