<?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 INFILE TXT NUMBER FOLLOW BY NEGATIVE SIGN in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/INFILE-TXT-NUMBER-FOLLOW-BY-NEGATIVE-SIGN/m-p/341652#M272772</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;new to SAS programming, tried to import raw data but how to convert the number follow with negative sign to negative number as the output missing value.&lt;/P&gt;&lt;P&gt;tried tp find solution but unable to solve it(believe wrong method), appreciated if you could spend sometime to guide me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA TESTING;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;INFILE DATALINES DLM='|' MISSOVER;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;INPUT H :$ G :$ K;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;IF MISSING(K) THEN&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;K=CATX('-',SUBSTR(K,1,LENGTH(K)-1));&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;DATALINES;&lt;BR /&gt;D&amp;nbsp;&amp;nbsp; &amp;nbsp;| ABC&lt;BR /&gt;E&amp;nbsp;&amp;nbsp; &amp;nbsp;| EFB&amp;nbsp;&amp;nbsp; &amp;nbsp;| 456&lt;BR /&gt;f&amp;nbsp;&amp;nbsp; &amp;nbsp;| WWL&amp;nbsp;&amp;nbsp; &amp;nbsp;| 567-&lt;BR /&gt;;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Mar 2017 16:15:36 GMT</pubDate>
    <dc:creator>sagulolo</dc:creator>
    <dc:date>2017-03-16T16:15:36Z</dc:date>
    <item>
      <title>INFILE TXT NUMBER FOLLOW BY NEGATIVE SIGN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-TXT-NUMBER-FOLLOW-BY-NEGATIVE-SIGN/m-p/341652#M272772</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;new to SAS programming, tried to import raw data but how to convert the number follow with negative sign to negative number as the output missing value.&lt;/P&gt;&lt;P&gt;tried tp find solution but unable to solve it(believe wrong method), appreciated if you could spend sometime to guide me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA TESTING;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;INFILE DATALINES DLM='|' MISSOVER;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;INPUT H :$ G :$ K;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;IF MISSING(K) THEN&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;K=CATX('-',SUBSTR(K,1,LENGTH(K)-1));&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;DATALINES;&lt;BR /&gt;D&amp;nbsp;&amp;nbsp; &amp;nbsp;| ABC&lt;BR /&gt;E&amp;nbsp;&amp;nbsp; &amp;nbsp;| EFB&amp;nbsp;&amp;nbsp; &amp;nbsp;| 456&lt;BR /&gt;f&amp;nbsp;&amp;nbsp; &amp;nbsp;| WWL&amp;nbsp;&amp;nbsp; &amp;nbsp;| 567-&lt;BR /&gt;;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 16:15:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-TXT-NUMBER-FOLLOW-BY-NEGATIVE-SIGN/m-p/341652#M272772</guid>
      <dc:creator>sagulolo</dc:creator>
      <dc:date>2017-03-16T16:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: INFILE TXT NUMBER FOLLOW BY NEGATIVE SIGN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-TXT-NUMBER-FOLLOW-BY-NEGATIVE-SIGN/m-p/341665#M272773</link>
      <description>&lt;PRE&gt;data testing;
  infile datalines dlm='|' missover;
  input h $ g $ k $;
  k_num=input(cats(ifc(index(k,"-")&amp;gt;0,"-",""),tranwrd(k,"-","")),best.);
datalines;
D    | ABC
E    | EFB    | 456
f    | WWL    | 567-
;
run;&lt;/PRE&gt;
&lt;P&gt;You will see several things from the above. &amp;nbsp;First, I have used a code window ({i} above where you post) this distinguishes code from text. &amp;nbsp;Secondly I use consitent lower case, and 2 spaces indentation in my code for readablitiy. &amp;nbsp;Finally, I use the input() function which takes character and converts to number. &amp;nbsp;First I decide if there is a "-" in the text, if so its negative, and concatenate a miinus with the number then input.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 16:43:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-TXT-NUMBER-FOLLOW-BY-NEGATIVE-SIGN/m-p/341665#M272773</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-03-16T16:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: INFILE TXT NUMBER FOLLOW BY NEGATIVE SIGN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-TXT-NUMBER-FOLLOW-BY-NEGATIVE-SIGN/m-p/341671#M272774</link>
      <description>thank you so much, it really help me a lot.</description>
      <pubDate>Thu, 16 Mar 2017 16:50:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-TXT-NUMBER-FOLLOW-BY-NEGATIVE-SIGN/m-p/341671#M272774</guid>
      <dc:creator>sagulolo</dc:creator>
      <dc:date>2017-03-16T16:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: INFILE TXT NUMBER FOLLOW BY NEGATIVE SIGN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-TXT-NUMBER-FOLLOW-BY-NEGATIVE-SIGN/m-p/341750#M272775</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;PRE&gt;data testing;
  infile datalines dlm='|' missover;
  input h $ g $ k $;
  k_num=input(cats(ifc(index(k,"-")&amp;gt;0,"-",""),tranwrd(k,"-","")),best.);
datalines;
D    | ABC
E    | EFB    | 456
f    | WWL    | 567-
;
run;&lt;/PRE&gt;
&lt;P&gt;You will see several things from the above. &amp;nbsp;First, I have used a code window ({i} above where you post) this distinguishes code from text. &amp;nbsp;Secondly I use consitent lower case, and 2 spaces indentation in my code for readablitiy. &amp;nbsp;Finally, I use the input() function which takes character and converts to number. &amp;nbsp;First I decide if there is a "-" in the text, if so its negative, and concatenate a miinus with the number then input.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;There is an INFORMAT for that but you get the programming for job security award.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data testing;
   infile datalines dlm='|' missover;
   input h $ g $ k :Trailsgn.;
   *k_num=input(cats(ifc(index(k,"-")&amp;gt;0,"-",""),tranwrd(k,"-","")),best.);
   datalines;
D    | ABC
E    | EFB    | 456
f    | WWL    | 567-
g    | WWL    | -567
;;;;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG title="Capture.PNG" alt="Capture.PNG" src="https://communities.sas.com/t5/image/serverpage/image-id/7794i816A3D1774495EF1/image-size/original?v=1.0&amp;amp;px=-1" border="0" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 20:38:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-TXT-NUMBER-FOLLOW-BY-NEGATIVE-SIGN/m-p/341750#M272775</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2017-03-16T20:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: INFILE TXT NUMBER FOLLOW BY NEGATIVE SIGN</title>
      <link>https://communities.sas.com/t5/SAS-Programming/INFILE-TXT-NUMBER-FOLLOW-BY-NEGATIVE-SIGN/m-p/341893#M272776</link>
      <description>&lt;P&gt;Yes, didn't know about that informat. &amp;nbsp;As for job security, if I wanted that I would have created at least one macro, with a macro list, and an Excel paramters file&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2017 09:28:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/INFILE-TXT-NUMBER-FOLLOW-BY-NEGATIVE-SIGN/m-p/341893#M272776</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-03-17T09:28:23Z</dc:date>
    </item>
  </channel>
</rss>

