As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


Difference between revisions of "Tips:Making Macro Variables READONLY"

From sasCommunity
Jump to: navigation, search
(tip ready)
(gardening)
 
(4 intermediate revisions by 3 users not shown)
Line 8: Line 8:
 
%* The macro %TRYIT will fail;
 
%* The macro %TRYIT will fail;
 
%tryit </source></div>  
 
%tryit </source></div>  
Did you know that you can now make your Global and Local [[macro variables]] READONLY?  New options on the %GLOBAL and %LOCAL statements allow you to not only make variables so that they cannot be inadvertently changed, but you can also assign them initial values.  The use of these options can help you avoid [http://www.caloxy.com/papers/62_TT04.pdf macro variable collisions], but there are dangers. Once specified as readonly, you can nolonger create local versions of this macro variable.  This can be a big problem if a called macro also attempts to create another instance of the macro variable - even using the %LOCAL statement.
+
Did you know that you can now make your Global and Local [[macro variables]] READONLY?  New options on the <big><source lang="sas" enclose="none">%GLOBAL</source></big> and <big><source lang="sas" enclose="none">%LOCAL</source></big> [[statements]] allow you to not only make variables so that they cannot be inadvertently changed, but you can also assign them initial values.  The use of these options can help you avoid [http://www.caloxy.com/papers/62_TT04.pdf macro variable collisions], but there are dangers. Once specified as readonly, you can no longer create local versions of this macro variable.  This can be a big problem if a called macro also attempts to create another instance of the macro variable - even using the <big><source lang="sas" enclose="none">%LOCAL</source></big> statement.
<!-- Insert any appropriate category tags - you can have as many CATEGORY tag lines as you want.
+
 
    it is important to put the category tags inside the <noinclude></noinclude> block so the categories are only applied to the tip page.
+
{{ExternalReadMore|http://support.sas.com/documentation/cdl/en/mcrolref/68140/HTML/default/viewer.htm#p1lhhti7fjxgb1n1fuiubqk11h4d.htm}}
-->
+
{{ExternalReadMore|http://support.sas.com/documentation/cdl/en/mcrolref/68140/HTML/default/viewer.htm#p0ivgabci0y2den1usf43mxdkpgp.htm}}
 +
{{clear}}
 +
<!-- Please do not edit below this line, EXCEPT when promoting a tip -->
 +
<div style="float:right">Submitted By [[User:ArtCarpenter|Art Carpenter]] ([[User talk:ArtCarpenter|talk]])</div>
 +
 
 
<noinclude>
 
<noinclude>
 
[[Category:Macro Language]]
 
[[Category:Macro Language]]
 
[[Category:%GLOBAL Statement]]
 
[[Category:%GLOBAL Statement]]
 
[[Category:%LOCAL Statement]]
 
[[Category:%LOCAL Statement]]
 +
[[Category:Tip in Use]]
 
</noinclude>
 
</noinclude>
{{ExternalReadMore|http://support.sas.com/documentation/cdl/en/mcrolref/68140/HTML/default/viewer.htm#p1lhhti7fjxgb1n1fuiubqk11h4d.htm}}
 
{{ExternalReadMore|http://support.sas.com/documentation/cdl/en/mcrolref/68140/HTML/default/viewer.htm#p0ivgabci0y2den1usf43mxdkpgp.htm}}
 
<!-- Please do not edit below this line, EXCEPT when promoting a tip -->
 
<div style="float:right">Submitted By [[User:ArtCarpenter|Art Carpenter]] ([[User talk:ArtCarpenter|talk]])</div>
 
[[Category:Tip Ready]]
 

Latest revision as of 15:18, 9 June 2017

%global/readonly dsn=clinics;
 
%macro tryit;
%local dsn;
%* does other stuff;
%mend tryit;
 
%* The macro %TRYIT will fail;
%tryit

Did you know that you can now make your Global and Local macro variables READONLY? New options on the %GLOBAL and %LOCAL statements allow you to not only make variables so that they cannot be inadvertently changed, but you can also assign them initial values. The use of these options can help you avoid macro variable collisions, but there are dangers. Once specified as readonly, you can no longer create local versions of this macro variable. This can be a big problem if a called macro also attempts to create another instance of the macro variable - even using the %LOCAL statement.

....see also

....see also


Submitted By Art Carpenter (talk)