<?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: How to correctly use proc format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-correctly-use-proc-format/m-p/770949#M244571</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp; thank you for your response. I followed the following suggestion to create the respective variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Multiple-data-under-a-variable/m-p/746480" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Multiple-data-under-a-variable/m-p/746480&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Tue, 28 Sep 2021 16:52:17 GMT</pubDate>
    <dc:creator>Nrjn7</dc:creator>
    <dc:date>2021-09-28T16:52:17Z</dc:date>
    <item>
      <title>How to correctly use proc format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-correctly-use-proc-format/m-p/770928#M244561</link>
      <description>&lt;P&gt;I was able to create the following where the inclusion and exclusion might have multiple criteria separated by comma.&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;exclusion_failed&lt;/TD&gt;&lt;TD&gt;inclusion_failed&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;exc_1&lt;/TD&gt;&lt;TD&gt;inc_3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;exc_1, exc_2&lt;/TD&gt;&lt;TD&gt;inc_1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;inc_1, inc_2, inc_3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;exc_2, exc_3&lt;/TD&gt;&lt;TD&gt;inc_2, inc_3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I properly apply format so the table then looks like this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;exclusion_failed&lt;/TD&gt;&lt;TD&gt;inclusion_failed&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1, 2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1,2,3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;2, 3&lt;/TD&gt;&lt;TD&gt;2,3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the code I used to format:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc format;&lt;/P&gt;&lt;P&gt;value $exclusion 'exc_1' = '1'&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;'exc_2' = '2'&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;'exc_3' = '3';&lt;/P&gt;&lt;P&gt;value $inclusion 'inc_1' = '1'&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;'inc_2' = '2'&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;'inc_3' = '3';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I apply the format, it only works for single criteria but for the ones separated by comma doesn't seem to be working, any suggestions.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 15:47:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-correctly-use-proc-format/m-p/770928#M244561</guid>
      <dc:creator>Nrjn7</dc:creator>
      <dc:date>2021-09-28T15:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to correctly use proc format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-correctly-use-proc-format/m-p/770942#M244567</link>
      <description>&lt;P&gt;Hi: How are you getting or creating the variables called exclusion_failed and inclusion_failed? I'm not clear how or where you are applying the format. If you already have character variable that contains a string of comma separated values, I would not expect your format to work as you envision. If the format works at all, it should only format part of the variable value where the variable contains commas.&lt;BR /&gt;Off hand, it might be easier to just use the tranwrd and compbl functions to just get rid of the exc_ and the inc_ pieces of the string.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1632846879554.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64201iCA8139D86115DAC0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1632846879554.png" alt="Cynthia_sas_0-1632846879554.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 16:35:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-correctly-use-proc-format/m-p/770942#M244567</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2021-09-28T16:35:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to correctly use proc format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-correctly-use-proc-format/m-p/770949#M244571</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp; thank you for your response. I followed the following suggestion to create the respective variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Multiple-data-under-a-variable/m-p/746480" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Multiple-data-under-a-variable/m-p/746480&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 16:52:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-correctly-use-proc-format/m-p/770949#M244571</guid>
      <dc:creator>Nrjn7</dc:creator>
      <dc:date>2021-09-28T16:52:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to correctly use proc format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-correctly-use-proc-format/m-p/770951#M244573</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/295245"&gt;@Nrjn7&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I was able to create the following where the inclusion and exclusion might have multiple criteria separated by comma.&lt;/P&gt;
&lt;TABLE border="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;ID&lt;/TD&gt;
&lt;TD&gt;exclusion_failed&lt;/TD&gt;
&lt;TD&gt;inclusion_failed&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;exc_1&lt;/TD&gt;
&lt;TD&gt;inc_3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;exc_1, exc_2&lt;/TD&gt;
&lt;TD&gt;inc_1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;inc_1, inc_2, inc_3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD&gt;exc_2, exc_3&lt;/TD&gt;
&lt;TD&gt;inc_2, inc_3&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do I properly apply format so the table then looks like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;ID&lt;/TD&gt;
&lt;TD&gt;exclusion_failed&lt;/TD&gt;
&lt;TD&gt;inclusion_failed&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;1, 2&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;1,2,3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;4&lt;/TD&gt;
&lt;TD&gt;2, 3&lt;/TD&gt;
&lt;TD&gt;2,3&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the code I used to format:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc format;&lt;/P&gt;
&lt;P&gt;value $exclusion 'exc_1' = '1'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;'exc_2' = '2'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;'exc_3' = '3';&lt;/P&gt;
&lt;P&gt;value $inclusion 'inc_1' = '1'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;'inc_2' = '2'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;'inc_3' = '3';&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I apply the format, it only works for single criteria but for the ones separated by comma doesn't seem to be working, any suggestions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;To apply a format the values must match the format definition. So if you have "multiple" values like "inc_1, inc_2, inc_3" then you have to have a definition in the format for "inc_1, inc_2, inc_3" = "1,2,3".&lt;/P&gt;
&lt;P&gt;Which is just one of the reasons why multiple values in a single variable are generally looked down upon. Because if your values are&amp;nbsp; "inc_1, inc_3, inc_2" that would require a separate entry in the format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may be able to do the conversion from the single values as you create the multiple version. Maybe. Provide data from &lt;STRONG&gt;before&lt;/STRONG&gt; the multiple values are created.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 16:59:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-correctly-use-proc-format/m-p/770951#M244573</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-09-28T16:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to correctly use proc format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-correctly-use-proc-format/m-p/770969#M244584</link>
      <description>&lt;P&gt;Does it have to be formats that you use?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How about this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    exclusion_failed=tranwrd(exclusion_failed,'exc_','');
    inclusion_failed=tranwrd(inclusion_failed,'inc_','');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;May I ask for the reason to do this? What can you do with '1,2,3' that you can't do with '&lt;SPAN&gt;inc_1, inc_2, inc_3'? And once you have '1,2,3', what is next? There may be much easier ways to accomplish the next step, or accomplish the end goal, if only we knew what you were trying to do.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 17:44:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-correctly-use-proc-format/m-p/770969#M244584</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-09-28T17:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to correctly use proc format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-correctly-use-proc-format/m-p/770979#M244587</link>
      <description>&lt;P&gt;Removing the unwanted text as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;already posted seems the easiest way to solve the problem. If you have to use formats, either define all combinations as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;said or use a loop to process each value of the strings (using the functions countw, scan and put).&lt;/P&gt;
&lt;P&gt;-.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 18:03:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-correctly-use-proc-format/m-p/770979#M244587</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-09-28T18:03:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to correctly use proc format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-correctly-use-proc-format/m-p/771133#M244667</link>
      <description>&lt;P&gt;You want this ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
infile cards expandtabs truncover;
input ID	exclusion_failed &amp;amp; $40. inclusion_failed &amp;amp; $40.;
cards;
1	exc_1	inc_3
2	exc_1, exc_2	inc_1
3	 .	inc_1, inc_2, inc_3
4	exc_2, exc_3	inc_2, inc_3
;

proc format;

value $exclusion 'exc_1' = '1'
                          'exc_2' = '2'

                          'exc_3' = '3';

value $inclusion 'inc_1' = '1'
                          'inc_2' = '2'

                          'inc_3' = '3';

run;
data want;
 set have;
 length new_exc new_inc $ 200;
 do i=1 to countw(exclusion_failed,', ');
   new_exc=catx(',',new_exc,put(scan(exclusion_failed,i,', '),$exclusion.));
 end;

 do i=1 to countw(inclusion_failed,', ');
   new_inc=catx(',',new_inc,put(scan(inclusion_failed,i,', '),$inclusion.));
 end;
drop i;
 run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Sep 2021 13:37:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-correctly-use-proc-format/m-p/771133#M244667</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-09-29T13:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to correctly use proc format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-correctly-use-proc-format/m-p/771136#M244670</link>
      <description>&lt;P&gt;Wide datasets or datasets with concatenated values are &lt;STRONG&gt;ALWAYS&lt;/STRONG&gt; harder to work with. Your formats would work if you hadn't made your dataset mostly useless.&lt;/P&gt;
&lt;P&gt;You can always "widen" data for reporting purposes, but that is the last step in your process.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 13:57:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-correctly-use-proc-format/m-p/771136#M244670</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-09-29T13:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to correctly use proc format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-correctly-use-proc-format/m-p/771460#M244819</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;Thanks for the feedback. This is required for creating reports as a final step.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 18:42:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-correctly-use-proc-format/m-p/771460#M244819</guid>
      <dc:creator>Nrjn7</dc:creator>
      <dc:date>2021-09-30T18:42:03Z</dc:date>
    </item>
  </channel>
</rss>

