<?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: format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/format/m-p/360657#M84966</link>
    <description>&lt;P&gt;Then do a datastep like this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (keep=c_all c_miss percentage);
set have end=done;
retain c_all 0 c_miss 0;
c_all + 1;
c_miss + (daystoadmit = .);
if done
then do;
  percentage = c_miss / c_all;
  put percentage percent8.2;
  call symput('percentage',put(percentage,percent8.2));
  call symput('percentage_r',put(percentage * 100,best.));
  output;
end;
run;

%put &amp;amp;percentage;
%put &amp;amp;percentage_r;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You'll see te values in the log, you have them in a dataset and in macro variables.&lt;/P&gt;</description>
    <pubDate>Tue, 23 May 2017 08:55:09 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-05-23T08:55:09Z</dc:date>
    <item>
      <title>format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/format/m-p/360646#M84958</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a numeric field called DAYSTOADMIT(contains values like &lt;STRONG&gt;0&lt;/STRONG&gt;, 1 ,33, 24 etc etc)&lt;/P&gt;&lt;P&gt;I am trying to apply formats to&amp;nbsp;assign 1 to&amp;nbsp;those that have a missing value by assigning them a value of 1 so i can summarize later using tabulate.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;I used the following format and from the resultant dataset when i say "&lt;STRONG&gt;where DAYSTOADMIT ne 0"&lt;/STRONG&gt; I AM GETTING 0 pulled up . It is surprising to me..&lt;/P&gt;&lt;P&gt;can someone explain why this is happening???&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;format&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;library&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=work;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;invalue&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; ADMIT&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;other=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;data want;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;set have;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;informat&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; DAYSTOADMIT &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;Admit.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;run;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 07:58:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/format/m-p/360646#M84958</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2017-05-23T07:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/format/m-p/360647#M84959</link>
      <description>&lt;P&gt;Assigning a format or informat NEVER changes the value of a variable.&lt;/P&gt;
&lt;P&gt;So the best option is&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
if daystoadmit = . then daystoadmit = 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And why don't you simply use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where daystoadmit = .;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;?&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 08:07:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/format/m-p/360647#M84959</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-23T08:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/format/m-p/360650#M84962</link>
      <description>&lt;P&gt;Thanks Kurt.&lt;/P&gt;&lt;P&gt;I think we need to use the following:Is that true when i want to get the total number of records later?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; want&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; have&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; daystoadmit &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; daystoadmit &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1; &lt;STRONG&gt;else daystoadmit&amp;nbsp;=0&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 08:17:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/format/m-p/360650#M84962</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2017-05-23T08:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/format/m-p/360652#M84963</link>
      <description>&lt;P&gt;If you just want to know the number of missings, do&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select count(*) from have where daystoadmit is missing;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or use a proc freq on daystoadmit and extract the observation for missing.&lt;/P&gt;
&lt;P&gt;So you don't have to change the value at all, and preserve the original information.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 08:34:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/format/m-p/360652#M84963</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-23T08:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/format/m-p/360654#M84964</link>
      <description>&lt;P&gt;Thanks again. Actually I need to do more than that. I had the same thing posted a few days ago and i got good response/help.&lt;/P&gt;&lt;P&gt;i am doing the :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;count of missing/Total records*100&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 08:40:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/format/m-p/360654#M84964</guid>
      <dc:creator>robertrao</dc:creator>
      <dc:date>2017-05-23T08:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/format/m-p/360657#M84966</link>
      <description>&lt;P&gt;Then do a datastep like this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (keep=c_all c_miss percentage);
set have end=done;
retain c_all 0 c_miss 0;
c_all + 1;
c_miss + (daystoadmit = .);
if done
then do;
  percentage = c_miss / c_all;
  put percentage percent8.2;
  call symput('percentage',put(percentage,percent8.2));
  call symput('percentage_r',put(percentage * 100,best.));
  output;
end;
run;

%put &amp;amp;percentage;
%put &amp;amp;percentage_r;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You'll see te values in the log, you have them in a dataset and in macro variables.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 08:55:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/format/m-p/360657#M84966</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-23T08:55:09Z</dc:date>
    </item>
  </channel>
</rss>

