<?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: FORMATS in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/FORMATS/m-p/179062#M45722</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Apart from a redundant comma in your proc format your code works fine for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to see the leading zeros in your initial numeric values, simply use the z3. format as below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC FORMAT;&lt;/P&gt;&lt;P&gt;VALUE MSDRG&lt;/P&gt;&lt;P&gt;001-017, 020-042, 113-117, 129-139="1"&lt;/P&gt;&lt;P&gt;OTHER="0";&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA FINAL_WITH_MSDRG;&lt;/P&gt;&lt;P&gt;FORMAT CODE Z3.;&lt;/P&gt;&lt;P&gt;CODE = 001;&lt;/P&gt;&lt;P&gt;OUTPUT;&lt;/P&gt;&lt;P&gt;CODE = 140;&lt;/P&gt;&lt;P&gt;OUTPUT;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA ELECTIVE_SURGICAL;&lt;/P&gt;&lt;P&gt;SET FINAL_WITH_MSDRG;&lt;/P&gt;&lt;P&gt;WHERE PUT(CODE, MSDRG.)="1";&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 31 May 2014 08:34:00 GMT</pubDate>
    <dc:creator>Scott_Mitchell</dc:creator>
    <dc:date>2014-05-31T08:34:00Z</dc:date>
    <item>
      <title>FORMATS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/FORMATS/m-p/179058#M45718</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;I have a numeric format for numeric variable;&lt;/P&gt;&lt;P&gt;but I am applying the same format on a charcecter variable (CODE)in the datastep.&lt;/P&gt;&lt;P&gt;could you help me figure out where I went wrong??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format;&lt;BR /&gt;value MSDRG&lt;BR /&gt;001-017, 020-042, 113-117, 129-139,="1"&lt;BR /&gt;other="0";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data elective_surgical;&lt;BR /&gt;set final_with_MSDRG;&lt;BR /&gt;where put(Code, MSDRG.)="1";&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 May 2014 21:15:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/FORMATS/m-p/179058#M45718</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2014-05-30T21:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: FORMATS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/FORMATS/m-p/179059#M45719</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That depends, what's not working?&lt;/P&gt;&lt;P&gt;The following works for me. I'm confused by your format though, 001-017 is the same as 1-17, if you have leading 0's you likely have a character variable not a numeric variable. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; have;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;do&lt;/SPAN&gt; code=&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;to&lt;/SPAN&gt; &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;200&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; &lt;/SPAN&gt;output&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;end&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;format&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;value&lt;/SPAN&gt; MSDRG&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #009193;"&gt;&lt;STRONG&gt;001&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;-&lt;/SPAN&gt;&lt;STRONG&gt;017&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;, &lt;/SPAN&gt;&lt;STRONG&gt;020&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;-&lt;/SPAN&gt;&lt;STRONG&gt;042&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;, &lt;/SPAN&gt;&lt;STRONG&gt;113&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;-&lt;/SPAN&gt;&lt;STRONG&gt;117&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;, &lt;/SPAN&gt;&lt;STRONG&gt;129&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;-&lt;/SPAN&gt;&lt;STRONG&gt;139&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #942193;"&gt;"1"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;other=&lt;SPAN style="color: #942193;"&gt;"0"&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; elective_surgical;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;set&lt;/SPAN&gt; have;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;where&lt;/SPAN&gt; put(Code, &lt;SPAN style="color: #009193;"&gt;MSDRG.&lt;/SPAN&gt;)=&lt;SPAN style="color: #942193;"&gt;"1"&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 May 2014 22:29:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/FORMATS/m-p/179059#M45719</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-05-30T22:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: FORMATS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/FORMATS/m-p/179060#M45720</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should have a separate charater value format where the value statement is Value $msdrg and use Put(code,$msdrg).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Character and numeric formats are different for a number of reasons.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 May 2014 22:40:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/FORMATS/m-p/179060#M45720</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-05-30T22:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: FORMATS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/FORMATS/m-p/179061#M45721</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If Code is character type, then you need transform it into numeric type ,since your format is numeric type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data have;
do i=1 to 200;
&amp;nbsp; code=put(i,best8. -l);output;
end;
drop i;
run;
 
proc format;
value MSDRG
001-017, 020-042, 113-117, 129-139="1"
other="0";
run;
 
 
data elective_surgical;
set have;
where put(input(Code,best8.), MSDRG.)="1";
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 May 2014 06:41:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/FORMATS/m-p/179061#M45721</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-05-31T06:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: FORMATS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/FORMATS/m-p/179062#M45722</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Apart from a redundant comma in your proc format your code works fine for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to see the leading zeros in your initial numeric values, simply use the z3. format as below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC FORMAT;&lt;/P&gt;&lt;P&gt;VALUE MSDRG&lt;/P&gt;&lt;P&gt;001-017, 020-042, 113-117, 129-139="1"&lt;/P&gt;&lt;P&gt;OTHER="0";&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA FINAL_WITH_MSDRG;&lt;/P&gt;&lt;P&gt;FORMAT CODE Z3.;&lt;/P&gt;&lt;P&gt;CODE = 001;&lt;/P&gt;&lt;P&gt;OUTPUT;&lt;/P&gt;&lt;P&gt;CODE = 140;&lt;/P&gt;&lt;P&gt;OUTPUT;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA ELECTIVE_SURGICAL;&lt;/P&gt;&lt;P&gt;SET FINAL_WITH_MSDRG;&lt;/P&gt;&lt;P&gt;WHERE PUT(CODE, MSDRG.)="1";&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 May 2014 08:34:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/FORMATS/m-p/179062#M45722</guid>
      <dc:creator>Scott_Mitchell</dc:creator>
      <dc:date>2014-05-31T08:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: FORMATS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/FORMATS/m-p/179063#M45723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you want to format a character variable to return another character value you can use the PUTC function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC FORMAT;&lt;/P&gt;&lt;P&gt;VALUE $MSDRG&lt;/P&gt;&lt;P&gt;"001"-"017"="1"&lt;/P&gt;&lt;P&gt;OTHER="0";&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA FINAL_WITH_MSDRG;&lt;/P&gt;&lt;P&gt;FORMAT CODE;&lt;/P&gt;&lt;P&gt;CODE = "001";&lt;/P&gt;&lt;P&gt;OUTPUT;&lt;/P&gt;&lt;P&gt;CODE = "140";&lt;/P&gt;&lt;P&gt;OUTPUT;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA ELECTIVE_SURGICAL;&lt;/P&gt;&lt;P&gt;SET FINAL_WITH_MSDRG;&lt;/P&gt;&lt;P&gt;ATTRIB STUFF FORMAT=$1.;&lt;/P&gt;&lt;P&gt;STUFF=PUTC(CODE, "$MSDRG.")="1";&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 May 2014 08:49:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/FORMATS/m-p/179063#M45723</guid>
      <dc:creator>Scott_Mitchell</dc:creator>
      <dc:date>2014-05-31T08:49:15Z</dc:date>
    </item>
  </channel>
</rss>

