<?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: input problem in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/input-problem/m-p/56194#M15699</link>
    <description>Hi.&lt;BR /&gt;
That column input method would be used.&lt;BR /&gt;
[pre]&lt;BR /&gt;
data temp;&lt;BR /&gt;
 input a 1 b 3 c 5 d 7;&lt;BR /&gt;
cards;&lt;BR /&gt;
  1 1 1&lt;BR /&gt;
2   2 2&lt;BR /&gt;
3 3   3&lt;BR /&gt;
4 4 4  &lt;BR /&gt;
;run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
    <pubDate>Wed, 29 Dec 2010 06:55:08 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2010-12-29T06:55:08Z</dc:date>
    <item>
      <title>input problem</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/input-problem/m-p/56193#M15698</link>
      <description>suppose I have following data:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
blank 1 1 1&lt;BR /&gt;
2 blank 2 2&lt;BR /&gt;
3 3 blank 3&lt;BR /&gt;
4 4 4 blank&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
The delimiter is a blank (" "). And the missing value is also denoted as a blank(i.e. " ". I type "blank" in the data just to clarify).&lt;BR /&gt;
&lt;BR /&gt;
what input code can work for such data?&lt;BR /&gt;
thanks.</description>
      <pubDate>Wed, 29 Dec 2010 05:42:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/input-problem/m-p/56193#M15698</guid>
      <dc:creator>littlestone</dc:creator>
      <dc:date>2010-12-29T05:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: input problem</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/input-problem/m-p/56194#M15699</link>
      <description>Hi.&lt;BR /&gt;
That column input method would be used.&lt;BR /&gt;
[pre]&lt;BR /&gt;
data temp;&lt;BR /&gt;
 input a 1 b 3 c 5 d 7;&lt;BR /&gt;
cards;&lt;BR /&gt;
  1 1 1&lt;BR /&gt;
2   2 2&lt;BR /&gt;
3 3   3&lt;BR /&gt;
4 4 4  &lt;BR /&gt;
;run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Wed, 29 Dec 2010 06:55:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/input-problem/m-p/56194#M15699</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2010-12-29T06:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: input problem</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/input-problem/m-p/56195#M15700</link>
      <description>Thank you for reply. However, what if raw data look like this:&lt;BR /&gt;
&lt;BR /&gt;
blank 1 1 1&lt;BR /&gt;
2 blank 22 2&lt;BR /&gt;
3 333 blank 3&lt;BR /&gt;
4444 4 4 blank</description>
      <pubDate>Wed, 29 Dec 2010 15:53:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/input-problem/m-p/56195#M15700</guid>
      <dc:creator>littlestone</dc:creator>
      <dc:date>2010-12-29T15:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: input problem</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/input-problem/m-p/56196#M15701</link>
      <description>Something like below could work:&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
  infile datalines dsd delimiter='|' truncover;&lt;BR /&gt;
  input @;&lt;BR /&gt;
  _infile_=tranwrd(trim(_infile_),'  ','|');&lt;BR /&gt;
  _infile_=tranwrd(trim(_infile_),' ','|');&lt;BR /&gt;
  input a b c d;&lt;BR /&gt;
  put a= b= c= d=;&lt;BR /&gt;
  datalines;&lt;BR /&gt;
blank 1 1 1&lt;BR /&gt;
2 blank blank 2&lt;BR /&gt;
3 333 blank 3&lt;BR /&gt;
4444 4 4 blank&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
...or even so (the left over blanks have now only the meaning of "delimiter"):&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
  infile datalines dsd delimiter='| ' truncover;&lt;BR /&gt;
  input @;&lt;BR /&gt;
  _infile_=tranwrd(trim(_infile_),'  ','|');&lt;BR /&gt;
  input a b c d;&lt;BR /&gt;
  put a= b= c= d=;&lt;BR /&gt;
  datalines;&lt;BR /&gt;
blank 1 1 1&lt;BR /&gt;
2 blank blank 2&lt;BR /&gt;
3 333 blank 3&lt;BR /&gt;
4444 4 4 blank&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick

Message was edited by: Patrick</description>
      <pubDate>Thu, 30 Dec 2010 00:41:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/input-problem/m-p/56196#M15701</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-12-30T00:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: input problem</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/input-problem/m-p/56197#M15702</link>
      <description>I would try:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
  infile datalines dsd delimiter='|' truncover;&lt;BR /&gt;
  length x $40;&lt;BR /&gt;
  input @;&lt;BR /&gt;
  _infile_=tranwrd(_infile_,'  ','|');&lt;BR /&gt;
  _infile_=tranwrd(_infile_,' ','|');&lt;BR /&gt;
  input a b c d;&lt;BR /&gt;
  datalines;&lt;BR /&gt;
  1 1 1&lt;BR /&gt;
2     2&lt;BR /&gt;
3 333   3&lt;BR /&gt;
4444 4 4  &lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
HTH,&lt;BR /&gt;
Art</description>
      <pubDate>Thu, 30 Dec 2010 22:53:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/input-problem/m-p/56197#M15702</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2010-12-30T22:53:06Z</dc:date>
    </item>
    <item>
      <title>Re: input problem</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/input-problem/m-p/56198#M15703</link>
      <description>the only problem seems to be that a blank item has space for itself on the input line as well as the delimiter and DSD infile option considers consecutive delimiters imply an empty item. So   just reduce two blanks to one. This is very similar to earlier posts, but uses only one tranwrd().[pre]data test ;&lt;BR /&gt;
    infile datalines dsd delimiter=' ' truncover;&lt;BR /&gt;
  input @  ;&lt;BR /&gt;
  _infile_= tranwrd( _infile_,'  ',' ' );&lt;BR /&gt;
  input a b c d;&lt;BR /&gt;
  put (_all_)(=)  ;&lt;BR /&gt;
datalines;&lt;BR /&gt;
  1 1 1&lt;BR /&gt;
2     2&lt;BR /&gt;
3 333   3&lt;BR /&gt;
4444 4 4&lt;BR /&gt;
;[/pre]* and here is a log of the step extended to demo the tranwrd() effect on _infile_;[pre]857  data demo ;&lt;BR /&gt;
858      infile datalines dsd delimiter=' ' truncover;&lt;BR /&gt;
859    input @  ;&lt;BR /&gt;
860    put                _infile_ $char20. +1 'before the fix' ;&lt;BR /&gt;
861    _infile_= tranwrd( _infile_,'  ',' ' );&lt;BR /&gt;
862    put                _infile_ $char20. +1 'after' ;&lt;BR /&gt;
863    input a b c d;&lt;BR /&gt;
864    put (_all_)(=)  ;&lt;BR /&gt;
865  datalines;&lt;BR /&gt;
&lt;BR /&gt;
  1 1 1              before the fix&lt;BR /&gt;
 1 1 1               after&lt;BR /&gt;
a=. b=1 c=1 d=1&lt;BR /&gt;
2     2              before the fix&lt;BR /&gt;
2   2                after&lt;BR /&gt;
a=2 b=. c=. d=2&lt;BR /&gt;
3 333   3            before the fix&lt;BR /&gt;
3 333  3             after&lt;BR /&gt;
a=3 b=333 c=. d=3&lt;BR /&gt;
4444 4 4             before the fix&lt;BR /&gt;
4444 4 4             after&lt;BR /&gt;
a=4444 b=4 c=4 d=.&lt;BR /&gt;
NOTE: The data set WORK.DEMO has 4 observations and 4 variables.&lt;BR /&gt;
NOTE: DATA statement&lt;BR /&gt;
[/pre]&lt;BR /&gt;
peterC</description>
      <pubDate>Tue, 04 Jan 2011 18:09:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/input-problem/m-p/56198#M15703</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-01-04T18:09:29Z</dc:date>
    </item>
    <item>
      <title>Re: input problem</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/input-problem/m-p/56199#M15704</link>
      <description>Thank you all for help. &lt;BR /&gt;
I apologize for not replying soon enough. I will try all your suggestions and get back to you.&lt;BR /&gt;
Again, thank you very much.</description>
      <pubDate>Tue, 04 Jan 2011 19:26:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/input-problem/m-p/56199#M15704</guid>
      <dc:creator>littlestone</dc:creator>
      <dc:date>2011-01-04T19:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: input problem</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/input-problem/m-p/56200#M15705</link>
      <description>i tried all codes and Mr. Peter.C's code worked best for me.&lt;BR /&gt;
&lt;BR /&gt;
Again thank you all for help. I really learned a lot.</description>
      <pubDate>Tue, 04 Jan 2011 21:53:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/input-problem/m-p/56200#M15705</guid>
      <dc:creator>littlestone</dc:creator>
      <dc:date>2011-01-04T21:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: input problem</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/input-problem/m-p/56201#M15706</link>
      <description>Hi.Actuall, Patrick and art297 's code is also right.&lt;BR /&gt;
If they put [ pre ] before their code and [ /pre ] after their code,that would not trim the blanks in code.&lt;BR /&gt;
&lt;BR /&gt;
Ksharp&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: Ksharp</description>
      <pubDate>Wed, 05 Jan 2011 01:47:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/input-problem/m-p/56201#M15706</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-01-05T01:47:33Z</dc:date>
    </item>
  </channel>
</rss>

