<?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 for negative numbers in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-format-for-negative-numbers/m-p/376358#M90337</link>
    <description>&lt;P&gt;That depends on what you're trying to do, which you didn't actually state in your question.&lt;/P&gt;
&lt;P&gt;Formats are used to control the display of a number. But 'Missing' is actually a character string, so are you tyring to map&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-1 -&amp;gt; . (numeric missing is a period)&lt;/P&gt;
&lt;P&gt;OR&lt;/P&gt;
&lt;P&gt;-1 -&amp;gt; Missing (word that will be in a report)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because formats only the control the display it's not actually recoded but you usually don't need that. If you do need it recoded, use a PUT() to recode it to a character value. &amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 16 Jul 2017 17:34:25 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-07-16T17:34:25Z</dc:date>
    <item>
      <title>Proc format for negative numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-format-for-negative-numbers/m-p/376345#M90331</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the dataset i'm using, missing observations are coded as -1.&lt;/P&gt;&lt;P&gt;I am running a format step and not sure how to recode the -1...&lt;/P&gt;&lt;P&gt;I currently have low-&amp;lt;1='missig', but I am not sure if this is the right/best way to do this.&lt;/P&gt;&lt;P&gt;Any other tips?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, what exactly does the low-&amp;lt;1 do?&lt;/P&gt;&lt;P&gt;Thank you all in advance.&lt;/P&gt;&lt;P&gt;KS&lt;/P&gt;</description>
      <pubDate>Sun, 16 Jul 2017 15:41:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-format-for-negative-numbers/m-p/376345#M90331</guid>
      <dc:creator>K_S</dc:creator>
      <dc:date>2017-07-16T15:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: Proc format for negative numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-format-for-negative-numbers/m-p/376349#M90333</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
picture neg (round)
0-high = 99.99
low - &amp;lt;0=099.99 (prefix='-')
;
run;
data want;
input x @@;
format x neg.;
datalines;
1.254 2.2 -1.5
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 16 Jul 2017 16:37:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-format-for-negative-numbers/m-p/376349#M90333</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-07-16T16:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: Proc format for negative numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-format-for-negative-numbers/m-p/376358#M90337</link>
      <description>&lt;P&gt;That depends on what you're trying to do, which you didn't actually state in your question.&lt;/P&gt;
&lt;P&gt;Formats are used to control the display of a number. But 'Missing' is actually a character string, so are you tyring to map&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-1 -&amp;gt; . (numeric missing is a period)&lt;/P&gt;
&lt;P&gt;OR&lt;/P&gt;
&lt;P&gt;-1 -&amp;gt; Missing (word that will be in a report)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because formats only the control the display it's not actually recoded but you usually don't need that. If you do need it recoded, use a PUT() to recode it to a character value. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Jul 2017 17:34:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-format-for-negative-numbers/m-p/376358#M90337</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-16T17:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: Proc format for negative numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-format-for-negative-numbers/m-p/376360#M90339</link>
      <description>&lt;P&gt;It really depends on what you want to do. If you want to create a format for displaying the value then I am not sure why a range is needed.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
  value neg1miss
     -1 = 'Missing'
    other = [best12.]
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the values are numbers (like a score or a measure) that you would want to use directly, say to report the mean score, then you should RECODE the data and not just use a FORMAT. &amp;nbsp;That way SAS will ignore the missing values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set have ;
  if var1 = -1 then var1=. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;You could create an INFORMAT to transform the data as it is read from a source text file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
  invalue neg1miss
     '-1' = .
    other = [32.]
  ;
run;
data want ;
  input (var1-var2) (:neg1miss.);
cards;
1 1 
-1 2 
3 -1 
;
proc freq data=want;
 tables var1-var2 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 16 Jul 2017 17:46:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-format-for-negative-numbers/m-p/376360#M90339</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-16T17:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: Proc format for negative numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-format-for-negative-numbers/m-p/376367#M90344</link>
      <description>&lt;P&gt;I would suggest changing the data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;if var1=-1 then var1=.M;&lt;/P&gt;
&lt;P&gt;if var2=-1 then var2=.M;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you were to print the data you would see "M" instead of "missing", but that might be acceptable. &amp;nbsp;But there are other advantages besides printing. &amp;nbsp;Suppose you try to calculate statistics. &amp;nbsp;Before you change the data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc means data=have;&lt;/P&gt;
&lt;P&gt;var var1;&lt;/P&gt;
&lt;P&gt;where var1 ne&amp;nbsp;-1;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The WHERE statement is required so that the missing VAR1 values don't get included in the calculations. &amp;nbsp;But that means you can only calculate statistics for one variable at a time. &amp;nbsp;If you included VAR2 in the VAR statement, the WHERE statement would throw out some nonmissing values for VAR2. &amp;nbsp;So changing the data (-1 becoming .M) lets you calculate statistics for all variables at once:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc means data=have;&lt;/P&gt;
&lt;P&gt;var var1 var2;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A WHERE statement is not needed, because PROC MEANS automatically tosses missing values from the calculations and keeps all valid (nonmissing) values.&lt;/P&gt;</description>
      <pubDate>Sun, 16 Jul 2017 18:25:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-format-for-negative-numbers/m-p/376367#M90344</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-16T18:25:24Z</dc:date>
    </item>
  </channel>
</rss>

