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:Reg Exp Substitution in Proc Format"

From sasCommunity
Jump to: navigation, search
m
(gardening)
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Did you know that PROC FORMAT in 9.3 allows regular expressions in INFORMAT and (user-written) function calls in FORMAT? You can even do the reg exp substitutions!  
+
Did you know that [[FORMAT procedure|PROC FORMAT]] in [[SAS]] Version 9.3 and later allows [[regular expressions]] in INFORMAT and (user-written) [[function]] calls in FORMAT? You can even do the reg exp substitutions!  
Let's try something fun. Read Rick's SGF2012 [http://support.sas.com/resources/papers/proceedings12/245-2012.pdf paper] and try to complete the chain reaction. Good luck!
+
Let's try something fun. Read Rick's SGF2012 [[Using the New Features in PROC FORMAT|paper]] and try to complete the chain reaction. Good luck!
 
<source lang="sas">
 
<source lang="sas">
 
proc format;
 
proc format;
Line 21: Line 21:
 
<div style="float:right">Submitted By [[User:Chang y chung|chang_y_chung]]</div>
 
<div style="float:right">Submitted By [[User:Chang y chung|chang_y_chung]]</div>
  
[[Category:Tip to be Reviewed]]
+
<noinclude>
 +
[[Category:Tip in Use]]
 +
</noinclude>

Latest revision as of 08:18, 29 December 2016

Did you know that PROC FORMAT in SAS Version 9.3 and later allows regular expressions in INFORMAT and (user-written) function calls in FORMAT? You can even do the reg exp substitutions! Let's try something fun. Read Rick's SGF2012 paper and try to complete the chain reaction. Good luck!

proc format;
   invalue $final 's/final/four/' (regexpe) = [$four.];
   invalue $four  's/four/square/' (regexpe) = [$square.];
   invalue $square 's/square/dance/' (regexpe) = [$dance.];
   /* your code here */
   invalue $travel 's/travel/guide/' (regexpe) = _same_;
run; quit;
 
data _null_;
   var = input("final", $final.);
   put var=;
run;
/* on log
var=guide
*/
Submitted By chang_y_chung