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
/* 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

One strongly suspects something in your data set named companys. Either their are missing values or the variable names are spelled differently than you used in the template.

 

I also would suggest running your Sgrender code without any macro variables.

View solution in original post

5 REPLIES 5
Gil_
Quartz | Level 8
The proc template runs and it says overwriting existing template/link :linechart stagragh linechart has been saved to sasuser.templat

The Marco the last part of code I rec a warning message
" the linechart statement named linechart will not be drawn because one or more of the required arguments were not supplied it tells me in blue 80k records were read for year 2020 ...I need help to determine missing arguments thanks again
Reeza
Super User

 

dynamic year="&year;"; /* Pass the year to the template */

 

 

Do you need the semicolon in the quotes? I suspect that's an issue. You may not even need quotes if it's defined as numeric value.  EDIT: You do need the quotes though.

 

dynamic year="&year";

 

Gil_
Quartz | Level 8
It didnt work rec same warning missing arguments the code I found in sas documents under how to create line chart statement ... the data I'm using looks like this
Day. Which is format Date9. Company formation $9. Total format best12. When I try the example code that pings the help folder it works
ballardw
Super User

One strongly suspects something in your data set named companys. Either their are missing values or the variable names are spelled differently than you used in the template.

 

I also would suggest running your Sgrender code without any macro variables.

Gil_
Quartz | Level 8
Got it had date instead of day

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
  • 5 replies
  • 971 views
  • 0 likes
  • 3 in conversation