<?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: Applying a format to only part of a comma delimited observation. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Applying-a-format-to-only-part-of-a-comma-delimited-observation/m-p/521234#M141401</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13255"&gt;@jimbobob&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Morning Fellow SASers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a field that is a concatenation of row exceptions into one observation separated by a comma example:&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Question: did you concatenate the rows?&lt;/P&gt;
&lt;P&gt;If so, the approach would be to use a format that addresses each single value instead of groups and use the formatted value when concatenating.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the value is coming to you already concatenated the split it apart and apply a single valued format to rebuild a new string.&lt;/P&gt;
&lt;P&gt;Something along:&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
value $status (default=8)
'GHI'    = 'Paid'
'RR2P'   = 'Not Paid'
'YTZ'    = 'Closed'
'Z1G2P'  = 'Weak'
other    = 'UNKNOWN'
;

data example;
   str1='GHI, RR2P, YTZ, Z1G2P, ABC';
   length str2 $ 100 temp1 temp2 $ 8;
   do i=1 to countw(str1);
      temp1  = scan(str1,i);
      temp2 = put(temp1,$status.);
      if temp2= 'UNKNOWN' then put "WARNING: Unknown code of: " temp1;
      str2=catx(', ',str2,temp2);
   end;&lt;BR /&gt;   drop temp1 temp2;
run;
 
&lt;/PRE&gt;
&lt;P&gt;Note the test of the value and a note in the log about a new value found. When you see one of those you would be able to add the value into the format with a formatted value and rerun to "fix" the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Dec 2018 18:27:04 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-12-13T18:27:04Z</dc:date>
    <item>
      <title>Applying a format to only part of a comma delimited observation.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Applying-a-format-to-only-part-of-a-comma-delimited-observation/m-p/521209#M141397</link>
      <description>&lt;P&gt;Morning Fellow SASers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a field that is a concatenation of row exceptions into one observation separated by a comma example:&lt;/P&gt;
&lt;TABLE width="395"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;
&lt;P&gt;&lt;STRONG&gt;OBS&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="142"&gt;
&lt;P&gt;&lt;STRONG&gt;EXCPS&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="189"&gt;
&lt;P&gt;&lt;STRONG&gt;Format Applied&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;A&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;GHI, RR2P, YTZ, Z1G2P&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;Paid, Not Paid, Closed, Weak&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;B&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;A4H, MNL, PJF6&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;New, Renew, Extension&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;C&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;D334, FTR, XL1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;Docs, Delinquent, Rate&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;D&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;THT, Z1G2P&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;THT, &lt;STRONG&gt;Weak&lt;/STRONG&gt;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can create a format with every CURRENT concatenated observation. But when a new EXCPS code&amp;nbsp;comes in that hasn't been defined in the format, I still want to apply the format to part of the observation. But right now when I apply the format, OBS D, shows "THT, Z1G2P". The EXCPS field can have anywhere from 1 to up to 10 codes in the field, The observation itself is always concatenated in a Alpha-Numeric order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it possible to apply a format to only part of a Observation?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Dec 2018 17:26:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Applying-a-format-to-only-part-of-a-comma-delimited-observation/m-p/521209#M141397</guid>
      <dc:creator>jimbobob</dc:creator>
      <dc:date>2018-12-13T17:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: Applying a format to only part of a comma delimited observation.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Applying-a-format-to-only-part-of-a-comma-delimited-observation/m-p/521215#M141398</link>
      <description>You cannot apply a format to part of an observation. You'll need to split them (look into SCAN()) and then concatenate them back. Within the format definition do you have an 'OTHER' option? I usually code OTHER='MISSING' or OTHER='CHECKME' so that it's clear when somethings gone wrong.</description>
      <pubDate>Thu, 13 Dec 2018 17:33:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Applying-a-format-to-only-part-of-a-comma-delimited-observation/m-p/521215#M141398</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-13T17:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: Applying a format to only part of a comma delimited observation.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Applying-a-format-to-only-part-of-a-comma-delimited-observation/m-p/521234#M141401</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13255"&gt;@jimbobob&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Morning Fellow SASers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a field that is a concatenation of row exceptions into one observation separated by a comma example:&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Question: did you concatenate the rows?&lt;/P&gt;
&lt;P&gt;If so, the approach would be to use a format that addresses each single value instead of groups and use the formatted value when concatenating.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the value is coming to you already concatenated the split it apart and apply a single valued format to rebuild a new string.&lt;/P&gt;
&lt;P&gt;Something along:&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
value $status (default=8)
'GHI'    = 'Paid'
'RR2P'   = 'Not Paid'
'YTZ'    = 'Closed'
'Z1G2P'  = 'Weak'
other    = 'UNKNOWN'
;

data example;
   str1='GHI, RR2P, YTZ, Z1G2P, ABC';
   length str2 $ 100 temp1 temp2 $ 8;
   do i=1 to countw(str1);
      temp1  = scan(str1,i);
      temp2 = put(temp1,$status.);
      if temp2= 'UNKNOWN' then put "WARNING: Unknown code of: " temp1;
      str2=catx(', ',str2,temp2);
   end;&lt;BR /&gt;   drop temp1 temp2;
run;
 
&lt;/PRE&gt;
&lt;P&gt;Note the test of the value and a note in the log about a new value found. When you see one of those you would be able to add the value into the format with a formatted value and rerun to "fix" the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Dec 2018 18:27:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Applying-a-format-to-only-part-of-a-comma-delimited-observation/m-p/521234#M141401</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-12-13T18:27:04Z</dc:date>
    </item>
  </channel>
</rss>

