BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
FredrikHansson
Obsidian | Level 7

The MVAR and NMVAR statements support default values according to the documentation. But I can't get it working... And I can't find any example code of MVAR/NMVAR using defaults.

 

EDIT: My google skills are poor. The documentation I found is for "Creating Tabular Templates" (see link above). Setting default values for mvar/nmvar does (unfortunately) not apply to GTL-templates.

 

EDIT2: This is the code I hoped could help. I don't get any warnings or errors in the logg. The default values are just not applyed.

proc template;
	define statgraph size_test;
		MVAR  SIZE_TEST_HEIGHT = '200px' 'picture height';
		NMVAR BLOCK_width = 150 'block width';
		begingraph /
			collation=binary
			pad=0
			designwidth=250px designheight=SIZE_TEST_HEIGHT;
			layout overlay / xaxisopts=(display=none) ;
				drawrectangle x=25 y=25 width=BLOCK_width height=15 / drawspace=graphpixel widthunit=pixel heightunit=pixel anchor=bottomleft  display=(fill);
			endlayout;
		endgraph;
	end;
run;



%let SIZE_TEST_HEIGHT = 200px;
%let BLOCK_width = 100;
proc sgrender template=size_test;
run;
%symdel SIZE_TEST_HEIGHT BLOCK_width;


* Calling the template hoping to use default values (does not work)	;
proc sgrender template=size_test;
run;

 

EDIT3: I didn't post this as a new question. I was trying to help in this thread: default values for DYNAMIC variables? - SAS Support Communities. I guess my answer was moved to a new thread by mods.

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

I am able to reproduce your results. It looks to me like the statgraph template and/or GTL does not respect the default values of macro variables in SAS 9.  The GTL does respect the default values in SAS Viya (SAS runtime programming environment), so perhaps the bug was fixed in Viya, but exists in the version of SAS 9 that you and I are running.

 

I think the default values for the MVAR/NMVAR variables work for other ODS templates, just not GTL. However, I am not sure about that.

View solution in original post

5 REPLIES 5
ballardw
Super User

You might consider sharing the code you are using and then the log if it doesn't work.

 

MVAR appears in several places and which one you are attempting is important:

Procedures using MVAR as an option include ODSLIST, ODSTEXT, ODSTABLE, Template that I am aware of. In some of these procedures MVAR appears within different statements for different reasons.

 

FredrikHansson
Obsidian | Level 7

Oups. I didn't pay attention to where I was reading (Tabular Templates and not GTL-templates). I edited my post. Several times...

ballardw
Super User

 

EDIT3: I didn't post this as a new question. I was trying to help in this thread: default values for DYNAMIC variables? - SAS Support Communities. I guess my answer was moved to a new thread by mods.

Possible. Since the other thread is more than 5 years old. If it wasn't an actual working addition to the thread then it may have been moved.

 

The link you have for Tabular templates is correct for tables, the equivalent for GTL graphs does not show use of default values, only text to describe the purpose of the macro variable. https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/odsproc/n0a28a83qd2du3n1g4warb7xa9df.htm  does not show any optional default value assignment. I think the internal link in the help linking to the Tabular Templates may be incorrect for graphics.

This link https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatug/n1j7cpxoazlv08n1fzajqrq7pyyr.htm

which is specifically about initializing dynamic mvar and nmvar variables does not show any option for default values. I would think that if default values were possible they would at least be mentioned here.

 

Rick_SAS
SAS Super FREQ

I am able to reproduce your results. It looks to me like the statgraph template and/or GTL does not respect the default values of macro variables in SAS 9.  The GTL does respect the default values in SAS Viya (SAS runtime programming environment), so perhaps the bug was fixed in Viya, but exists in the version of SAS 9 that you and I are running.

 

I think the default values for the MVAR/NMVAR variables work for other ODS templates, just not GTL. However, I am not sure about that.

FredrikHansson
Obsidian | Level 7

Thats good news. It looks like we're about to upgrade to Viya within the next year.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 758 views
  • 4 likes
  • 3 in conversation