<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: PROC FORMAT with REGEXP in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FORMAT-with-REGEXP/m-p/32045#M4768</link>
    <description>I wanted to apply the format over an existing dataset without creating new variable by substr... but it seems to be impossible...</description>
    <pubDate>Thu, 14 May 2009 14:34:36 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-05-14T14:34:36Z</dc:date>
    <item>
      <title>PROC FORMAT with REGEXP</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FORMAT-with-REGEXP/m-p/32040#M4763</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
Is it possible (and how) to use regular expresions in PROC FORMAT procedure?&lt;BR /&gt;
&lt;BR /&gt;
I have the following data&lt;BR /&gt;
&lt;BR /&gt;
DATA test;&lt;BR /&gt;
 INPUT variable;&lt;BR /&gt;
 CARDS;&lt;BR /&gt;
AAA&lt;BR /&gt;
ABB&lt;BR /&gt;
AC&lt;BR /&gt;
BAA&lt;BR /&gt;
BBB&lt;BR /&gt;
BC&lt;BR /&gt;
C&lt;BR /&gt;
CCC&lt;BR /&gt;
;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
and I would like to use something like like this&lt;BR /&gt;
PROC FORMAT;&lt;BR /&gt;
 VALUE myformat &lt;BR /&gt;
   "A*"="USA"&lt;BR /&gt;
   "BA*"="Canada"&lt;BR /&gt;
   "BC*"="Mexico"&lt;BR /&gt;
   OTHER="rest of world";&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
(If the string stars by "A", then "USA"; if starts by "BA" then Canada,...)&lt;BR /&gt;
&lt;BR /&gt;
Is there any way haw to manage this?&lt;BR /&gt;
&lt;BR /&gt;
Thank you in advance!&lt;BR /&gt;
Jaroslav</description>
      <pubDate>Thu, 14 May 2009 10:01:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FORMAT-with-REGEXP/m-p/32040#M4763</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-05-14T10:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FORMAT with REGEXP</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FORMAT-with-REGEXP/m-p/32041#M4764</link>
      <description>"big birdie" had a project along the lines to use regex in user defined informats.&lt;BR /&gt;
Lack of user interest/demand seems to have pushed it.&lt;BR /&gt;
However, what your example demonstrates can be achieved without regex, by using ranges &lt;BR /&gt;
PROC FORMAT;&lt;BR /&gt;
VALUE myformat &lt;BR /&gt;
"A" - "AZ" ="USA"&lt;BR /&gt;
"BA" - 'BAZ' ="Canada"&lt;BR /&gt;
"BC" - BCZ ="Mexico"&lt;BR /&gt;
OTHER="rest of world";&lt;BR /&gt;
here I used "Z" but if you are generating a cntlin= data set, you could use high values 'FF'x</description>
      <pubDate>Thu, 14 May 2009 10:46:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FORMAT-with-REGEXP/m-p/32041#M4764</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-05-14T10:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FORMAT with REGEXP</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FORMAT-with-REGEXP/m-p/32042#M4765</link>
      <description>why regexp?&lt;BR /&gt;
&lt;BR /&gt;
PROC FORMAT;&lt;BR /&gt;
VALUE myformat&lt;BR /&gt;
"A" - &amp;lt; "B"="USA"&lt;BR /&gt;
"BA" - &amp;lt; "BC"="Canada"&lt;BR /&gt;
"BC" - "BC["="Mexico"&lt;BR /&gt;
OTHER="rest of world";  * [ comes after Z in the ascii sequence;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
Can't test here, but I think this should work.</description>
      <pubDate>Thu, 14 May 2009 11:03:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FORMAT-with-REGEXP/m-p/32042#M4765</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2009-05-14T11:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FORMAT with REGEXP</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FORMAT-with-REGEXP/m-p/32043#M4766</link>
      <description>My motivation tu use regexp was to be able to define format like&lt;BR /&gt;
&lt;BR /&gt;
PROC FORMAT;&lt;BR /&gt;
 VALUE myformat2&lt;BR /&gt;
  ".D*"="Daily data"&lt;BR /&gt;
  ".M*"="Monthly data"&lt;BR /&gt;
  ".A*"="Anual data";&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
(depending on the second position of the string, without using extra variable nor reading all dataset for posible values and using them to define the format).&lt;BR /&gt;
&lt;BR /&gt;
Does anybody know how to solve this 2nd example?&lt;BR /&gt;
&lt;BR /&gt;
Thank you very much</description>
      <pubDate>Thu, 14 May 2009 13:23:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FORMAT-with-REGEXP/m-p/32043#M4766</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-05-14T13:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FORMAT with REGEXP</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FORMAT-with-REGEXP/m-p/32044#M4767</link>
      <description>use substr() to start looking at a specific position. &lt;BR /&gt;
OK, regex allows you to look for a pattern at a non-specific position.</description>
      <pubDate>Thu, 14 May 2009 14:20:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FORMAT-with-REGEXP/m-p/32044#M4767</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2009-05-14T14:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FORMAT with REGEXP</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FORMAT-with-REGEXP/m-p/32045#M4768</link>
      <description>I wanted to apply the format over an existing dataset without creating new variable by substr... but it seems to be impossible...</description>
      <pubDate>Thu, 14 May 2009 14:34:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FORMAT-with-REGEXP/m-p/32045#M4768</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-05-14T14:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FORMAT with REGEXP</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FORMAT-with-REGEXP/m-p/32046#M4769</link>
      <description>Associate your output format name to your existing SAS variable, using the SAS FORMAT statement?&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 14 May 2009 15:39:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FORMAT-with-REGEXP/m-p/32046#M4769</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-05-14T15:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FORMAT with REGEXP</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FORMAT-with-REGEXP/m-p/32047#M4770</link>
      <description>I reckon it is possible.&lt;BR /&gt;
2 ways you could still use the formatted value like you want without reading the dataset before hand:&lt;BR /&gt;
&lt;BR /&gt;
1) bulldozer&lt;BR /&gt;
=========&lt;BR /&gt;
proc format ; &lt;BR /&gt;
  value $myformat &lt;BR /&gt;
   "AD" - "AD" 'ff'x='daily'    /* as many entries as possible prefixes */&lt;BR /&gt;
   "BD" - "BD" 'ff'x='daily'&lt;BR /&gt;
   "CD" - "CD" 'ff'x='daily'&lt;BR /&gt;
   "DD" - "DD" 'ff'x='daily'&lt;BR /&gt;
   ....&lt;BR /&gt;
   "AM" - "AM" 'ff'x='monthly'&lt;BR /&gt;
   "BM" - "BM" 'ff'x='monthly'&lt;BR /&gt;
   ...&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
2) view&lt;BR /&gt;
========&lt;BR /&gt;
proc format ; &lt;BR /&gt;
  value $myformat &lt;BR /&gt;
   "D" - "D" 'ff'x='daily'&lt;BR /&gt;
   "M" - "M" 'ff'x='monthly'&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
data MYDATA_V/view=MYDATA_V;&lt;BR /&gt;
  set MYDATA;&lt;BR /&gt;
  MYVAR2=substr(MYVAR,2);&lt;BR /&gt;
  format MYVAR2 $x.;&lt;BR /&gt;
proc print data=MYDATA_V(drop=MYVAR); &lt;BR /&gt;
run;</description>
      <pubDate>Thu, 14 May 2009 21:22:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FORMAT-with-REGEXP/m-p/32047#M4770</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2009-05-14T21:22:27Z</dc:date>
    </item>
  </channel>
</rss>

