Posted By

webonomic on 10/02/08


Tagged

sql match regular Expression proc


Versions (?)


Advertising

Website Promotion DIRECTORY is a crucial factor for all websites that need to gain better organic search engine rankings and increase website traffic.
Submitting your website as part of your Web Promotion strategy to our SEO friendly and high traffic Business Directory for review is an excellent way to gain a valuable backlink and increase your websites visibility online.

Submit Site


Use Regular Expressions in Proc SQL


Published in: SAS 






URL: http://jaredprins.squarespace.com/blog/2008/10/7/some-sas-code-snippets.html

You can use regular expressions within SQL. This can be quite powerful in selecting data that matches certain conditions. The following example shows a simple regular expression which selects only quarterly periods from a table containing years, quarters & months.

Expand | Embed | Plain Text
  1. data test ;
  2.  
  3. length period $ 7 ;
  4.  
  5. input period ;
  6.  
  7. cards ;
  8.  
  9. 2005
  10.  
  11. 2005Q1
  12.  
  13. 2005JAN
  14.  
  15. ;;
  16.  
  17. run ;
  18.  
  19. proc sql;
  20.  
  21. create table qtrs as
  22.  
  23. select *
  24.  
  25. from test
  26.  
  27. where prxmatch("/\d\d\d\d[qQ][1-4]/",period) ;
  28.  
  29. quit;
  30.  
  31. proc print data=qtrs ;
  32.  
  33. run ;

Report this snippet 

You need to login to post a comment.

Download royalty free graphics