<?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: Reading Multiple Records per Observation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-Multiple-Records-per-Observation/m-p/300287#M63405</link>
    <description>&lt;P&gt;Modify your data step like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data info;
infile "/folders/myfolders/SAS Practice.txt" truncover;
input Fname:$6. Lname :$6.;
input Address  $30.;
input city_state_zip $100.;
length city $30 state $2;
words = countw(city_state_zip);
zipcode = input(scan(city_state_zip,words),best.);
state = scan(city_state_zip,words-1); 
do i = 1 to words - 2;
  city = catx(' ', trim(city),scan(city_state_zip,i));
drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 23 Sep 2016 05:46:19 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-09-23T05:46:19Z</dc:date>
    <item>
      <title>Reading Multiple Records per Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Multiple-Records-per-Observation/m-p/300248#M63393</link>
      <description>&lt;P&gt;Is anyone can help with this data set ??&lt;/P&gt;&lt;P&gt;I'm a starter on SAS.&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LEE ATHNOS&lt;BR /&gt;1215 RAINTREE CIRCLE&lt;BR /&gt;PHOENIX AZ 85044&lt;BR /&gt;HEIDIE BAKER&lt;BR /&gt;1751 DIEHL ROAD&lt;BR /&gt;VIENNA VA 22124&lt;BR /&gt;MYRON BARKER&lt;BR /&gt;131 DONERAIL DRIVE&lt;BR /&gt;ATLANTA GA 30363&lt;BR /&gt;JOYCE BENET&lt;BR /&gt;85 MAPAVENUE&lt;BR /&gt;MENLO PARK CA 94025&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 01:04:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Multiple-Records-per-Observation/m-p/300248#M63393</guid>
      <dc:creator>Rockyxiu</dc:creator>
      <dc:date>2016-09-23T01:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Multiple Records per Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Multiple-Records-per-Observation/m-p/300254#M63395</link>
      <description>&lt;P&gt;Reading data from multiple lines is not an issue as such. The challenge with the data you've posted is that we don't know what's on which line - so for example when does a new address start.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does your data contain anything additional to what you've posted - eg. at the beginning of the line some sort of an indicator value telling us if the line contains the name, the street address and so on?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 01:43:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Multiple-Records-per-Observation/m-p/300254#M63395</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-09-23T01:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Multiple Records per Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Multiple-Records-per-Observation/m-p/300261#M63397</link>
      <description>&lt;P&gt;&lt;FONT size="2"&gt;Thank you for the reply Patrick. &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I believe the first line contains field of Fname and Lname;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;the second line contains field of Address (with street name and number) ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;the third line contains field of city, state and zipcode.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I wrote the code as such :&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;data info;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; infile "/folders/myfolders/SAS Practice.txt"; &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; input #1 &amp;nbsp; &amp;nbsp;Fname:$6. &amp;nbsp; Lname :$6.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;#2 &amp;nbsp; &amp;nbsp;Address : $21.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;#3 &amp;nbsp; &amp;nbsp;City : $10. &amp;nbsp; State :$2. &amp;nbsp; Zipcode;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp; But the result only showed &amp;nbsp;number on the address , and incomplete city.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&amp;nbsp;Could you tell me where it went wrong? Thanks.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 02:03:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Multiple-Records-per-Observation/m-p/300261#M63397</guid>
      <dc:creator>Rockyxiu</dc:creator>
      <dc:date>2016-09-23T02:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Multiple Records per Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Multiple-Records-per-Observation/m-p/300270#M63400</link>
      <description>&lt;P&gt;Two issues (one small, one large).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, remove the colons for ADDRESS and CITY. &amp;nbsp;That's what stops the INPUT statement when it hits a blank, rather than reading the full 21 (or the full 10) characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, the third line will be much more difficult to work with because some city names contain two words instead of one. &amp;nbsp;You could read the entire line as one long variable, then count the number of words in it to determine which piece(s) go into which variables.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 03:17:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Multiple-Records-per-Observation/m-p/300270#M63400</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-09-23T03:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Multiple Records per Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Multiple-Records-per-Observation/m-p/300271#M63401</link>
      <description>&lt;P&gt;Because a City can be 2 words, you won't be able to do a straight read for line 3. Unless you have two spaces between your other fields which is unlikely in the real world. If this is a class room example it may.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You'll need to read the line in as one string and then parse it. Parse it out backwards, last field is zip, second last is state and the remaining is city.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you sure you're using the Colon correctly here? I don't think you need it in all cases. It's used to read text with embedded blanks. Would that be true with First/Last Name?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 03:18:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Multiple-Records-per-Observation/m-p/300271#M63401</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-23T03:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Multiple Records per Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Multiple-Records-per-Observation/m-p/300273#M63402</link>
      <description>&lt;P&gt;This gets things in, I'll leave the parsing of the final line to you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data info;
informat fname lname $15.;
input #1    Fname $   Lname  $
	  #2    Address  $30.
	  #3    String3  $30.;
cards;
LEE ATHNOS
1215 RAINTREE CIRCLE
PHOENIX AZ 85044
HEIDIE BAKER
1751 DIEHL ROAD
VIENNA VA 22124
MYRON BARKER
131 DONERAIL DRIVE
ATLANTA GA 30363
JOYCE BENET
85 MAPAVENUE
MENLO PARK CA 94025
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Sep 2016 03:22:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Multiple-Records-per-Observation/m-p/300273#M63402</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-23T03:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Multiple Records per Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Multiple-Records-per-Observation/m-p/300282#M63403</link>
      <description>&lt;P&gt;According to:&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000146292.htm#a000146303" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000146292.htm#a000146303&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the input statement can be written also as:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;INPUT fname $10 lname $10 / address $30 / strung3 $30;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The / tells SAS to continue on next line.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 05:09:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Multiple-Records-per-Observation/m-p/300282#M63403</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-09-23T05:09:23Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Multiple Records per Observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Multiple-Records-per-Observation/m-p/300287#M63405</link>
      <description>&lt;P&gt;Modify your data step like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data info;
infile "/folders/myfolders/SAS Practice.txt" truncover;
input Fname:$6. Lname :$6.;
input Address  $30.;
input city_state_zip $100.;
length city $30 state $2;
words = countw(city_state_zip);
zipcode = input(scan(city_state_zip,words),best.);
state = scan(city_state_zip,words-1); 
do i = 1 to words - 2;
  city = catx(' ', trim(city),scan(city_state_zip,i));
drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Sep 2016 05:46:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Multiple-Records-per-Observation/m-p/300287#M63405</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-09-23T05:46:19Z</dc:date>
    </item>
  </channel>
</rss>

