<?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: how to fix the data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-fix-the-data/m-p/488800#M127445</link>
    <description>&lt;P&gt;Delimiters are not optional.&amp;nbsp; There needs to be a logical way of identifying where one item starts and finishes.&amp;nbsp; In your example this is not possible.&amp;nbsp; Therefore, due to this daft data you need to read it all in one big string, then write code to post process it into your required format.&amp;nbsp; Simply put wrong data format means more work for you.&lt;/P&gt;
&lt;PRE&gt;data want;
  length str $200;
  infile datalines dlm="-";
  input str $;
  age=scan(str,-1," ");
  name=substr(str,1,findc(strip(str)," ","b"));
datalines;
happy new year 22
advance 23
;
run;&lt;/PRE&gt;
&lt;P&gt;Me, I would be sending this back with all due haste, or putting my required resource hours up considerably.&lt;/P&gt;
&lt;P&gt;Do note, I use delimiter="-" in the above code to essentially tell the system not to use blanks.&lt;/P&gt;</description>
    <pubDate>Wed, 22 Aug 2018 09:04:38 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-08-22T09:04:38Z</dc:date>
    <item>
      <title>how to fix the data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-fix-the-data/m-p/488793#M127442</link>
      <description>&lt;P&gt;data want ;&lt;BR /&gt;input name $15. age ;&lt;BR /&gt;cards ;&lt;BR /&gt;happy new year 22&lt;BR /&gt;advance 23&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;if we run program it gives first record but it doesn't give second record&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 08:31:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-fix-the-data/m-p/488793#M127442</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2018-08-22T08:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to fix the data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-fix-the-data/m-p/488794#M127443</link>
      <description>&lt;P&gt;If you have blanks in data items, use a delimiter that is not a blank, or you will have to resort to unnecessarily complicated programming:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
infile cards dlm=',';
input name :$15. age;
cards;
happy new year,22
advance,23
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Aug 2018 08:38:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-fix-the-data/m-p/488794#M127443</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-22T08:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to fix the data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-fix-the-data/m-p/488795#M127444</link>
      <description>without using delimiter=','</description>
      <pubDate>Wed, 22 Aug 2018 08:44:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-fix-the-data/m-p/488795#M127444</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2018-08-22T08:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to fix the data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-fix-the-data/m-p/488800#M127445</link>
      <description>&lt;P&gt;Delimiters are not optional.&amp;nbsp; There needs to be a logical way of identifying where one item starts and finishes.&amp;nbsp; In your example this is not possible.&amp;nbsp; Therefore, due to this daft data you need to read it all in one big string, then write code to post process it into your required format.&amp;nbsp; Simply put wrong data format means more work for you.&lt;/P&gt;
&lt;PRE&gt;data want;
  length str $200;
  infile datalines dlm="-";
  input str $;
  age=scan(str,-1," ");
  name=substr(str,1,findc(strip(str)," ","b"));
datalines;
happy new year 22
advance 23
;
run;&lt;/PRE&gt;
&lt;P&gt;Me, I would be sending this back with all due haste, or putting my required resource hours up considerably.&lt;/P&gt;
&lt;P&gt;Do note, I use delimiter="-" in the above code to essentially tell the system not to use blanks.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 09:04:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-fix-the-data/m-p/488800#M127445</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-22T09:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to fix the data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-fix-the-data/m-p/488802#M127446</link>
      <description>&lt;P&gt;Don't be an idiot and make your life hard for no reason. Inserting a suitable delimiter is child's play compared to the hoops you have to jump through otherwise.&lt;/P&gt;
&lt;P&gt;eg if you positively know you have only two items and that the second will NEVER contain a blank, you can do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
infile cards truncover;
input line $80.;
name = substr(line,1,length(line) - length(scan(line,-1)));
age = input(scan(line,-1),best.);
drop line;
cards;
happy new year 22
advance 23
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But if there are other columns that contain blanks, it gets progressively harder.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Up to the point where you go to the one who sent you this with a shotgun in your hand and shoot her/him with a crazy smile on your face. After which you are taken away by some muscular guys with friendly faces in white suits and a jacket that closes in the back.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 09:05:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-fix-the-data/m-p/488802#M127446</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-22T09:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to fix the data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-fix-the-data/m-p/488902#M127509</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685"&gt;@thanikondharish&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;without using delimiter=','&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why not? If you don't like commas for a delimiter pick something else like | or * or #.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are reading data that&amp;nbsp;is in fixed column format such that a value always ends in column 15, then this will be possible just specify the columns in the input statement.. But if you are dealing with data where the start and end positions change then you will either have to 1) add a delimiter of some sort or 2) read the entire data line as one string variable and then parse it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 14:37:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-fix-the-data/m-p/488902#M127509</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-22T14:37:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to fix the data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-fix-the-data/m-p/488994#M127539</link>
      <description>it means without using delimiters&lt;BR /&gt;</description>
      <pubDate>Wed, 22 Aug 2018 18:02:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-fix-the-data/m-p/488994#M127539</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2018-08-22T18:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to fix the data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-fix-the-data/m-p/489002#M127541</link>
      <description>&lt;P&gt;I could repeat what &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt; and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; already said: data without delimiters is nothing more but useless crap. In your example, you could use the code already posted to get the data, but as soon as the data is more complex, maintaining the code required will become time consuming, hard work.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 18:35:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-fix-the-data/m-p/489002#M127541</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2018-08-22T18:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: how to fix the data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-fix-the-data/m-p/489032#M127554</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685"&gt;@thanikondharish&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;it means without using delimiters&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;42&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 20:13:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-fix-the-data/m-p/489032#M127554</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-22T20:13:21Z</dc:date>
    </item>
  </channel>
</rss>

