/ Published in: SAS
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
/*pull out all comments with specific words*/
data commentsdata;set surveydata;
if _n_=1 then do;
retain re;
re = prxparse(’/words|to|match/i’); /* the /i here means Case insensitive match */
if missing(re) then do;
putlog ‘ERROR: regex is malformed’;
stop;
end;
end;
if prxmatch(re,Comments); /* Comments is the name of the variable with the comments text */
run;
/*Regular Expressions*/
/*
^ start of field
s* (maybe with whitespace at the front)
[A-Z] a letter from A to Z
d a digit
[A-Z] A to Z again
a space
d a digit
[A-Z] A to Z again
d a digit
s* possible whitespace
$ end of field
*/
data new;
set YourData;
if _n_=1 then do;
re = prxparse(’/^s*[A-Z]d[A-Z] d[A-Z]ds*$/’);
if missing (re) then stop;
end;
if prxmatch(re,YourNameField);
run;
URL: http://jaredprins.squarespace.com/blog/2008/3/31/string-matching.html
Comments
 Subscribe to comments
                    Subscribe to comments
                
                