<?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 QUERY in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-QUERY/m-p/913281#M359970</link>
    <description>&lt;P&gt;Personally I would modify the program that reads the data to separate the values into multiple variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Question: did anyone tell you that this change to multiple values was going to occur? If not you have what can become a serious issue with data reliability in general and depending on how you read your files you may have other issues related to changing data structures.&lt;/P&gt;
&lt;P&gt;You really do not want multiple values in a SAS data set variable. Really, it causes problems with analysis and reporting and can make graphing nearly impossible to be meaningful. For one thing what do you do when you have a mix of values like&lt;/P&gt;
&lt;P&gt;EXL1|EXL2&lt;/P&gt;
&lt;P&gt;EXL2|EXL1&lt;/P&gt;
&lt;P&gt;If those are supposed to be considered as the same that will be very hard to deal with and require additional manipulation of the data to make it so. And the approach gets worse as soon as someone adds a third (or 4th or 5th) value.&lt;/P&gt;</description>
    <pubDate>Sun, 28 Jan 2024 18:56:05 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-01-28T18:56:05Z</dc:date>
    <item>
      <title>PROC FORMAT QUERY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-QUERY/m-p/913278#M359967</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have set up a format to be applied to a column that can come with three values - EXL1 , EXL2 and EXL3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc Format;
Value $EXCLPOST 
'EXL1' = 'ACTIVE BLOCKS'
'EXL2' = 'INACTIVE BLOCKS'
'EXL3' = 'INVESTIGATION BLOCKS'
Run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When this format was applied against the dataset for that column, it works just fine&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
DATA EXL_DAILY_DATA;
input EXL_FLAG $200.;
datalines;
EXL1
EXL2
;
run;
 
 
DATA EXL_DAILY_DATA;
input EXL_FLAG $200.;
datalines;
EXL1
EXL2
;
run;
 
DATA EXL_DAILY_DATA;
set EXL_DAILY_DATA;
format EXL_FLAG $EXCLPOST.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now I have started receiving data where the column could have multiple values in any combination separated by a pipe. For Eg:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA EXL_DAILY_DATA;
input EXL_FLAG $200.;
datalines;
EXL1|EXL2
EXL2|EXL3
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now when the format is applied it will not work and will only display the pipe delimited values that came in the input. &lt;BR /&gt;&lt;BR /&gt;How can i modify the format in a way that it applies the format to the individual values and come out as &lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ACTIVE BLOCKS | INACTIVE BLOCKS
INACTIVE BLOCKS | INVESTIGATION BLOCKS&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 28 Jan 2024 17:46:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-QUERY/m-p/913278#M359967</guid>
      <dc:creator>Anuz</dc:creator>
      <dc:date>2024-01-28T17:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FORMAT QUERY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-QUERY/m-p/913280#M359969</link>
      <description>&lt;P&gt;Separate the pipe-delimited fields into individual variables, one for each "word". Then apply the format to each variable.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jan 2024 18:42:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-QUERY/m-p/913280#M359969</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-01-28T18:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FORMAT QUERY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-QUERY/m-p/913281#M359970</link>
      <description>&lt;P&gt;Personally I would modify the program that reads the data to separate the values into multiple variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Question: did anyone tell you that this change to multiple values was going to occur? If not you have what can become a serious issue with data reliability in general and depending on how you read your files you may have other issues related to changing data structures.&lt;/P&gt;
&lt;P&gt;You really do not want multiple values in a SAS data set variable. Really, it causes problems with analysis and reporting and can make graphing nearly impossible to be meaningful. For one thing what do you do when you have a mix of values like&lt;/P&gt;
&lt;P&gt;EXL1|EXL2&lt;/P&gt;
&lt;P&gt;EXL2|EXL1&lt;/P&gt;
&lt;P&gt;If those are supposed to be considered as the same that will be very hard to deal with and require additional manipulation of the data to make it so. And the approach gets worse as soon as someone adds a third (or 4th or 5th) value.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jan 2024 18:56:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-QUERY/m-p/913281#M359970</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-01-28T18:56:05Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FORMAT QUERY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-QUERY/m-p/913283#M359971</link>
      <description>&lt;P&gt;Which other values in our input would demand that these values be combined in a single observation?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd rather read these double values into multiple observations.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jan 2024 21:38:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-QUERY/m-p/913283#M359971</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-01-28T21:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FORMAT QUERY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-QUERY/m-p/913286#M359974</link>
      <description>Thank you for your reply. &lt;BR /&gt;Yes. been told it was changing into the format i put into the example.&lt;BR /&gt;&lt;BR /&gt;It is only ever going to be one or the combination of the three values. &lt;BR /&gt;No analysis is to be done on this data. It is just display what it means. &lt;BR /&gt;&lt;BR /&gt;From what you saying it seems the best option might be a tranwrd if applying the format across is not going to be feasible</description>
      <pubDate>Sun, 28 Jan 2024 23:18:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-QUERY/m-p/913286#M359974</guid>
      <dc:creator>Anuz</dc:creator>
      <dc:date>2024-01-28T23:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FORMAT QUERY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-QUERY/m-p/913291#M359976</link>
      <description>&lt;P&gt;If you just want to display your data as is then just add to your PROC FORMAT like so:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc Format;
Value $EXCLPOST 
'EXL1' = 'ACTIVE BLOCKS'
'EXL2' = 'INACTIVE BLOCKS'
'EXL3' = 'INVESTIGATION BLOCKS'
'EXL1|EXL2' = 'ACTIVE BLOCKS | INACTIVE BLOCKS'
'EXL2|EXL3' = 'INACTIVE BLOCKS | INVESTIGATION BLOCKS'
;
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Jan 2024 00:15:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-QUERY/m-p/913291#M359976</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2024-01-29T00:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FORMAT QUERY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-QUERY/m-p/913300#M359980</link>
      <description>&lt;P&gt;Character formats only work on the full value (string) and not on substrings.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to continue using a format then one option would be to create a function and then use this function in the format as done in below sample code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover;
  input exl_flag $200.;
  datalines;
EXL1|EXL2
EXL2|EXL3
EXL1
EXL2
EXL2|EXL9
;

proc fcmp outlib=work.funcs.myfuncs;
  function EXCLPOST(instr $) $;
    length outstr $60;
    outstr=tranwrd(instr,'EXL1','ACTIVE BLOCKS');;
    outstr=tranwrd(outstr,'EXL2','INACTIVE BLOCKS');;
    outstr=tranwrd(outstr,'EXL3','INVESTIGATION BLOCKS');;
    return(outstr);
  endsub;
run;

options cmplib=work.funcs;

proc format;
  value $exclpost(default=60)
    other=[exclpost()]
  ;
run;

proc print data=have;
  format exl_flag $exclpost.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1706493607144.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93031i909C894E248EF031/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1706493607144.png" alt="Patrick_0-1706493607144.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2024 02:00:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-FORMAT-QUERY/m-p/913300#M359980</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-01-29T02:00:07Z</dc:date>
    </item>
  </channel>
</rss>

