<?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: sas data input in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sas-data-input/m-p/240657#M44431</link>
    <description>&lt;P&gt;You can't. &amp;nbsp;There is no logical way of knowing if a space is related to the text, or as a delimiter. &amp;nbsp;Now you could process the imported string, however I would suggest you get the file sent in a decent robust format such as CSV.&lt;/P&gt;</description>
    <pubDate>Wed, 23 Dec 2015 13:12:31 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2015-12-23T13:12:31Z</dc:date>
    <item>
      <title>sas data input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-data-input/m-p/240649#M44428</link>
      <description>&lt;P&gt;I have the below code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The variable State has few values with space in&amp;nbsp;between&amp;nbsp;(eg:&amp;nbsp;&lt;SPAN&gt;South Carolina&lt;/SPAN&gt;). I want to read those values without modifying the data but modifying the input statement. Any kind of suggestion is appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data prog;&lt;BR /&gt;input State $ EnterDate Size;&lt;BR /&gt;datalines;&lt;BR /&gt;Delaware 07DEC1787 1955&lt;BR /&gt;Pennsylvania 12DEC1787 44820&lt;BR /&gt;New Jersey 18DEC1787 7418&lt;BR /&gt;Georgia 02JAN1788 57918&lt;BR /&gt;Connecticut 09JAN1788 4845&lt;BR /&gt;Massachusetts 06FEB1788 7838&lt;BR /&gt;Maryland 28APR1788 9775&lt;BR /&gt;South Carolina 23MAY1788 30111&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Dec 2015 12:17:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-data-input/m-p/240649#M44428</guid>
      <dc:creator>Rafi</dc:creator>
      <dc:date>2015-12-23T12:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: sas data input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-data-input/m-p/240652#M44429</link>
      <description>&lt;P&gt;In your real data, are you&amp;nbsp;sure that you&amp;nbsp;have a space (with the same HEX code) as delimiter?&lt;/P&gt;
&lt;P&gt;If yes, try to get new data, one format is with all char values embedded within double quotes.&lt;/P&gt;
&lt;P&gt;If that's not possible, I would read the whole record into one variable, then search for the start position of your date, and assign preceding&amp;nbsp;string to state.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Dec 2015 12:39:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-data-input/m-p/240652#M44429</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2015-12-23T12:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: sas data input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-data-input/m-p/240657#M44431</link>
      <description>&lt;P&gt;You can't. &amp;nbsp;There is no logical way of knowing if a space is related to the text, or as a delimiter. &amp;nbsp;Now you could process the imported string, however I would suggest you get the file sent in a decent robust format such as CSV.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Dec 2015 13:12:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-data-input/m-p/240657#M44431</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-12-23T13:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: sas data input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-data-input/m-p/240659#M44432</link>
      <description>&lt;P&gt;As others have suggested, it might be easier to modify the data.&amp;nbsp; But it can be done.&amp;nbsp; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data prog;&lt;/P&gt;
&lt;P&gt;length state1 state2 $ 15 state $ 20;&lt;/P&gt;
&lt;P&gt;informat EnterDate date9.;&lt;/P&gt;
&lt;P&gt;input @;&lt;/P&gt;
&lt;P&gt;if countw(_infile_)=4 then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; input state1 $ state2 $ EnterDate&amp;nbsp; size;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; state = trim(state1) || ' ' || state2;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;else input state $ EnterDate size;&lt;/P&gt;
&lt;P&gt;format EnterDate yymmdd10.;&lt;/P&gt;
&lt;P&gt;drop state1 state2;&lt;BR /&gt;datalines;&lt;BR /&gt;Delaware 07DEC1787 1955&lt;BR /&gt;Pennsylvania 12DEC1787 44820&lt;BR /&gt;New Jersey 18DEC1787 7418&lt;BR /&gt;Georgia 02JAN1788 57918&lt;BR /&gt;Connecticut 09JAN1788 4845&lt;BR /&gt;Massachusetts 06FEB1788 7838&lt;BR /&gt;Maryland 28APR1788 9775&lt;BR /&gt;South Carolina 23MAY1788 30111&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notice that you cannot read EnterDate as a numeric variable unless you apply an informat.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note, this code is untested.&amp;nbsp; It's probably fine as is, but may require small changes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Dec 2015 13:51:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-data-input/m-p/240659#M44432</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-12-23T13:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: sas data input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-data-input/m-p/240660#M44433</link>
      <description>&lt;P&gt;If you can controll the formatting of the input file then force there to be two spaces between the state name and the date. Then you can use the &amp;amp; modifier on the input statement. Otherwise you will need to add some logic. In this case since state names do not contain digits and your date values always start with a digit it is easy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data prog;
  length State $20 EnterDate Size 8;
  input State $20. @;
  x=indexc(state,'0123456789');
  if x&amp;gt;0 then state=substr(state,1,x-1);
  else x=length(state)+2;
  input @x EnterDate date9. size ;
  format enterdate date9. size comma7.;
  drop x;
datalines;
Delaware 07DEC1787 1955
Pennsylvania 12DEC1787 44820
New Jersey 18DEC1787 7418
Georgia 02JAN1788 57918
Connecticut 09JAN1788 4845
Massachusetts 06FEB1788 7838
Maryland 28APR1788 9775
South Carolina 23MAY1788 30111
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Dec 2015 13:58:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-data-input/m-p/240660#M44433</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-12-23T13:58:28Z</dc:date>
    </item>
  </channel>
</rss>

