<?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 Reg Data Reading in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Reg-Data-Reading/m-p/51754#M14237</link>
    <description>Reading Data with spaces&lt;BR /&gt;
&lt;BR /&gt;
data l;&lt;BR /&gt;
input no address city age ;&lt;BR /&gt;
cards;&lt;BR /&gt;
1, main road near hospital   ,mumbai, 30&lt;BR /&gt;
2,govt area  ,pune,38&lt;BR /&gt;
3,central area,near adminstrative building ,Patna,40&lt;BR /&gt;
&lt;BR /&gt;
in the observation there are some spaces and i cannot decalre the length as the length is differ from one observation to another.how can i read it.and in the third observation there is a comma in the observation also&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Output&lt;BR /&gt;
&lt;BR /&gt;
no                 address                                  city  age &lt;BR /&gt;
&lt;BR /&gt;
1  main road near hospital                        mumbai  30&lt;BR /&gt;
2  govt area                                             pune      38&lt;BR /&gt;
3  central area near adminstrative building  Patna     40</description>
    <pubDate>Tue, 07 Jul 2009 08:42:04 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-07-07T08:42:04Z</dc:date>
    <item>
      <title>Reg Data Reading</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Reg-Data-Reading/m-p/51754#M14237</link>
      <description>Reading Data with spaces&lt;BR /&gt;
&lt;BR /&gt;
data l;&lt;BR /&gt;
input no address city age ;&lt;BR /&gt;
cards;&lt;BR /&gt;
1, main road near hospital   ,mumbai, 30&lt;BR /&gt;
2,govt area  ,pune,38&lt;BR /&gt;
3,central area,near adminstrative building ,Patna,40&lt;BR /&gt;
&lt;BR /&gt;
in the observation there are some spaces and i cannot decalre the length as the length is differ from one observation to another.how can i read it.and in the third observation there is a comma in the observation also&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Output&lt;BR /&gt;
&lt;BR /&gt;
no                 address                                  city  age &lt;BR /&gt;
&lt;BR /&gt;
1  main road near hospital                        mumbai  30&lt;BR /&gt;
2  govt area                                             pune      38&lt;BR /&gt;
3  central area near adminstrative building  Patna     40</description>
      <pubDate>Tue, 07 Jul 2009 08:42:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Reg-Data-Reading/m-p/51754#M14237</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-07-07T08:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: Reg Data Reading</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Reg-Data-Reading/m-p/51755#M14238</link>
      <description>Hi.&lt;BR /&gt;
&lt;BR /&gt;
For reading data through cards, with delimited data, this would suffice:&lt;BR /&gt;
&lt;BR /&gt;
data l;&lt;BR /&gt;
length NO 8 ADDRESS $200 CITY $50 AGE 8;&lt;BR /&gt;
input; * read line;&lt;BR /&gt;
&lt;BR /&gt;
* split line;&lt;BR /&gt;
NO=inputn(scan(_infile_,1,','),'best.');&lt;BR /&gt;
CITY=reverse(scan(reverse(_infile_),2,','));&lt;BR /&gt;
AGE=inputn(reverse(scan(reverse(_infile_),1,',')),'best.');&lt;BR /&gt;
ADDRESS=scan(_infile_,2,',');&lt;BR /&gt;
cards;&lt;BR /&gt;
1, main road near hospital ,mumbai, 30&lt;BR /&gt;
2,govt area ,pune,38&lt;BR /&gt;
3,central area,near adminstrative building ,Patna,40&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
But this code will not have the desired behavior for the 3rd row.&lt;BR /&gt;
&lt;BR /&gt;
For this, use regular expression parsing:&lt;BR /&gt;
&lt;BR /&gt;
data l;&lt;BR /&gt;
length NO 8 ADDRESS $200 CITY $50 AGE 8;&lt;BR /&gt;
input;&lt;BR /&gt;
drop _:;&lt;BR /&gt;
* prepare reg. expression for text parsing;&lt;BR /&gt;
_EXPR='s/([ 0-9]*),(.*),(.*),([ 0-9]*)/\1#\2#\3#\4/i';&lt;BR /&gt;
_REGX=prxparse(_EXPR);&lt;BR /&gt;
_PRX=prxchange(_REGX,1,_infile_);&lt;BR /&gt;
&lt;BR /&gt;
* split parsed text into desired variables;&lt;BR /&gt;
NO=inputn(cats(scan(_PRX,1,'#')),'best.');&lt;BR /&gt;
ADDRESS=cats(scan(_PRX,2,'#'));&lt;BR /&gt;
CITY=cats(scan(_PRX,3,'#'));&lt;BR /&gt;
AGE=inputn(cats(scan(_PRX,4,'#')),'best.');&lt;BR /&gt;
cards;&lt;BR /&gt;
1, main road near hospital ,mumbai, 30&lt;BR /&gt;
2,govt area ,pune,38&lt;BR /&gt;
3,central area,near adminstrative building ,Patna,40&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Check here for regular expression info:&lt;BR /&gt;
&lt;A href="http://www.regular-expressions.info/tutorial.html" target="_blank"&gt;http://www.regular-expressions.info/tutorial.html&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Check here for the regular expression functions online documentation:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a002295977.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a002295977.htm&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;.</description>
      <pubDate>Tue, 07 Jul 2009 10:07:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Reg-Data-Reading/m-p/51755#M14238</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2009-07-07T10:07:08Z</dc:date>
    </item>
  </channel>
</rss>

