Revision: 8655
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 2, 2008 13:16 by webonomic
Initial Code
data test ; length period $ 7 ; input period ; cards ; 2005 2005Q1 2005JAN ;; run ; proc sql; create table qtrs as select * from test where prxmatch("/\d\d\d\d[qQ][1-4]/",period) ; quit; proc print data=qtrs ; run ;
Initial URL
http://jaredprins.squarespace.com/blog/2008/10/7/some-sas-code-snippets.html
Initial Description
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.
Initial Title
Use Regular Expressions in Proc SQL
Initial Tags
sql
Initial Language
SAS