<?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: Help Reading in Data in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Help-Reading-in-Data/m-p/17038#M3208</link>
    <description>Thanks ballardw, that did fix the issue with the states</description>
    <pubDate>Thu, 24 Feb 2011 19:47:21 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2011-02-24T19:47:21Z</dc:date>
    <item>
      <title>Help Reading in Data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-Reading-in-Data/m-p/17032#M3202</link>
      <description>Seems like there should be a simple solution here, but I'm struggling to find it.&lt;BR /&gt;
&lt;BR /&gt;
Trying to read in data from a .dat file. Here's an example of the first 2 entries:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Generic College&lt;BR /&gt;
1234 Main St&lt;BR /&gt;
New York, NY                   12345&lt;BR /&gt;
718 555-1234&lt;BR /&gt;
One Star Liberal Arts&lt;BR /&gt;
Another Generic College&lt;BR /&gt;
567 Main St&lt;BR /&gt;
Boston, MA                23456&lt;BR /&gt;
617 555-5678&lt;BR /&gt;
Three Star Engineering&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Each entry has School Name on the first line, followed by street address then city, st &amp;amp; zip code followed by area code &amp;amp; phone # &amp;amp; then a generic rating scale (one-five star) &amp;amp; the focus of the school&lt;BR /&gt;
&lt;BR /&gt;
How I tried to read in the data:&lt;BR /&gt;
input name $ ;&lt;BR /&gt;
input address $ ;&lt;BR /&gt;
input city $ st $ zip $ ;&lt;BR /&gt;
input areacode $ phone $ ;&lt;BR /&gt;
input star $1-10 focus $ ;&lt;BR /&gt;
&lt;BR /&gt;
I'm using $ for all since I'm not actually manipulating the area or zip codes as numerical factors. I'm also using input in this fashion as I thought it would input in each line just as I wrote it and then I do do some kind of do loop to repeat throughout the rest of the data (a few thousand entries). However, it's not quite outputting it as planned. Iit's only reading info on each line up to the first space (ie - 1234 as the address instead of 1234 main st).&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I'm at a loss of how to read in the data when each entry is separated on multiple lines. Each address &amp;amp; name and city is differing in length, so it's not like I can just use "input name $1-34." I think if I can get over this small hurdle that I can use a do loop to read in successive entries. Every dataset I've used/seen with SAS has had info posted in a very vanilla fashion:&lt;BR /&gt;
name address city state zip phone stars focus&lt;BR /&gt;
Where all info for each entry is on the same line, making it easier to read in&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Any suggestions/advice for me to follow?</description>
      <pubDate>Thu, 24 Feb 2011 16:41:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-Reading-in-Data/m-p/17032#M3202</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-24T16:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: Help Reading in Data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-Reading-in-Data/m-p/17033#M3203</link>
      <description>Try using a line pointer (/);&lt;BR /&gt;
input name $ / address $ / city $ /  etc.&lt;BR /&gt;
&lt;BR /&gt;
the slash skips it to the next line of data.</description>
      <pubDate>Thu, 24 Feb 2011 16:50:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-Reading-in-Data/m-p/17033#M3203</guid>
      <dc:creator>GreggB</dc:creator>
      <dc:date>2011-02-24T16:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: Help Reading in Data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-Reading-in-Data/m-p/17034#M3204</link>
      <description>Gregg is right : use slashes to go and read the next line.&lt;BR /&gt;
To avoid stopping on the first space, specify the informats this way (not just $ but $ followed by the maximum length you would expect). The : before the $ tells SAS to stop when it encounters the delimiter (specify one in your INFILE statement, because default is blank !) or the end of the line.&lt;BR /&gt;
[pre]&lt;BR /&gt;
input name :$100. / address :$20. / city :$50. st $2. +1 zip $5. &lt;BR /&gt;
     / areacode $3. +1 phone $8. / star $10. focus :$50. ;[/pre]&lt;BR /&gt;
In this code, I use : when I don't know how long the values will be, but if I know the exact length (as for State, Zipcode of phone numbers) I don't mention any so that SAS reads exactly that number of characters.&lt;BR /&gt;
&lt;BR /&gt;
Hope it helps.&lt;BR /&gt;
Olivier</description>
      <pubDate>Thu, 24 Feb 2011 17:07:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-Reading-in-Data/m-p/17034#M3204</guid>
      <dc:creator>Olivier</dc:creator>
      <dc:date>2011-02-24T17:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: Help Reading in Data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-Reading-in-Data/m-p/17035#M3205</link>
      <description>Thanks for the quick responses!&lt;BR /&gt;
&lt;BR /&gt;
Quick question on the deilimiter. What should I specify it as? On the first &amp;amp; second line (name &amp;amp; address), it's just the end of the line that tells me it's time for the next entry, On the other 3rd line I'd have a comma to tell me the city is done and the last line has only a single space separating the star level with the school focus (on the final line,I'm thinking of counting the word "star" as it's own category and just dropping it so only the number shows in the output)</description>
      <pubDate>Thu, 24 Feb 2011 17:28:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-Reading-in-Data/m-p/17035#M3205</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-24T17:28:02Z</dc:date>
    </item>
    <item>
      <title>Re: Help Reading in Data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-Reading-in-Data/m-p/17036#M3206</link>
      <description>&lt;B&gt;&lt;U&gt;Update&lt;/U&gt;&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
Code I've used to get to this point:&lt;BR /&gt;
  data school ;&lt;BR /&gt;
    infile 'school.dat' DLM=' ' dsd;&lt;BR /&gt;
	input name &amp;amp; :$100. / address &amp;amp; :$30. / city &amp;amp; :$20. st $ zip $ 31-35&lt;BR /&gt;
     / areacode $3. phone $8. / star $ star2 $focus &amp;amp; :$50. ;&lt;BR /&gt;
	 drop star2;&lt;BR /&gt;
 run ;&lt;BR /&gt;
  proc print data=school (obs=10);&lt;BR /&gt;
    title 'Generic Title' ;&lt;BR /&gt;
run ;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
This gives me everything from zip code to the focus without issue. It also gives me the address without any problems&lt;BR /&gt;
&lt;BR /&gt;
However, the state is always connected to the city in the output (and so nothing shows up under state). Some of the schools listed also have nicknames attached (such as "The" Ohio State University). On these such schools, the only part of the name that shows up is The (without the quotation marks)&lt;BR /&gt;
&lt;BR /&gt;
Any more ideas on how to handle these 2 smaller issues?</description>
      <pubDate>Thu, 24 Feb 2011 18:05:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-Reading-in-Data/m-p/17036#M3206</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-24T18:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: Help Reading in Data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-Reading-in-Data/m-p/17037#M3207</link>
      <description>You can have multiple delimiters specified. So DLM=' ,' should treat the comma between city and state as desired.</description>
      <pubDate>Thu, 24 Feb 2011 19:05:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-Reading-in-Data/m-p/17037#M3207</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2011-02-24T19:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: Help Reading in Data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-Reading-in-Data/m-p/17038#M3208</link>
      <description>Thanks ballardw, that did fix the issue with the states</description>
      <pubDate>Thu, 24 Feb 2011 19:47:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-Reading-in-Data/m-p/17038#M3208</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-24T19:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: Help Reading in Data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-Reading-in-Data/m-p/17039#M3209</link>
      <description>1 last question&lt;BR /&gt;
&lt;BR /&gt;
I'm trying to turn the alphabetical spelling of the stars (one, two, etc) into numeric characters&lt;BR /&gt;
&lt;BR /&gt;
If I don't input the star rating as a character variable, it doesn't show up in the output (specifically in proc print, the star column is all .'s)&lt;BR /&gt;
&lt;BR /&gt;
If I try to do if thens (if star=one then stars =1, etc), then I'm told that variable one (all the way through five) are uninitialized&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Seems like excel's find &amp;amp; replace function would be easier than using SAS here. What am I missing?</description>
      <pubDate>Thu, 24 Feb 2011 21:24:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-Reading-in-Data/m-p/17039#M3209</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-24T21:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: Help Reading in Data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-Reading-in-Data/m-p/17040#M3210</link>
      <description>You are missing quotes around one i.e. star="one".  Keep in mind that matching in SAS is case sensitive.  You might want to do if upcase(star)="ONE".  There might also be a SAS informat to read character versions of numbers but I'm not as sure about that.</description>
      <pubDate>Thu, 24 Feb 2011 21:34:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-Reading-in-Data/m-p/17040#M3210</guid>
      <dc:creator>RickM</dc:creator>
      <dc:date>2011-02-24T21:34:18Z</dc:date>
    </item>
    <item>
      <title>Re: Help Reading in Data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-Reading-in-Data/m-p/17041#M3211</link>
      <description>Thanks RickM! Evidently I've been staring at these 10,000 entries far too long today</description>
      <pubDate>Thu, 24 Feb 2011 21:38:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-Reading-in-Data/m-p/17041#M3211</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-24T21:38:57Z</dc:date>
    </item>
    <item>
      <title>Re: Help Reading in Data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Help-Reading-in-Data/m-p/17042#M3212</link>
      <description>If you want very five rows to be a observation, then would be easy.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data temp(drop=_: position length);&lt;BR /&gt;
 infile datalines truncover;&lt;BR /&gt;
 input #1 name  $100.&lt;BR /&gt;
       #2 address  $100.&lt;BR /&gt;
       #3 _city  $100.&lt;BR /&gt;
       #4 areacode : $10. phone : $20.&lt;BR /&gt;
       #5 _star  $100.;&lt;BR /&gt;
 city=scan(_city,1,',');&lt;BR /&gt;
 st=scan(_city,-2,', ');&lt;BR /&gt;
 zip=scan(_city,-1,', ');&lt;BR /&gt;
 star=catx(' ',scan(_star,1),scan(_star,2));&lt;BR /&gt;
 call scan(_star,3,position,length);&lt;BR /&gt;
 focus=substr(_star,position);&lt;BR /&gt;
datalines;&lt;BR /&gt;
Generic College&lt;BR /&gt;
1234 Main St&lt;BR /&gt;
New York, NY 12345&lt;BR /&gt;
718 555-1234&lt;BR /&gt;
One Star Liberal Arts&lt;BR /&gt;
Another Generic College&lt;BR /&gt;
567 Main St&lt;BR /&gt;
Boston, MA 23456&lt;BR /&gt;
617 555-5678&lt;BR /&gt;
Three Star Engineering&lt;BR /&gt;
;&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>Fri, 25 Feb 2011 02:03:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Help-Reading-in-Data/m-p/17042#M3212</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-02-25T02:03:46Z</dc:date>
    </item>
  </channel>
</rss>

