<?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 Reading SAS data in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Reading-SAS-data/m-p/68135#M19510</link>
    <description>Hi All,&lt;BR /&gt;
&lt;BR /&gt;
Many times I get stuck in reading the data files in SAS with variables starting and ending at different positions and I use a long method of making every observation in the data of same length (with length of a variable as maximum length of the observation in that column). If it is required to work on say 1 million of rows then the process becomes almost next to impossible / time consuming. &lt;BR /&gt;
&lt;BR /&gt;
Suppose I have the sample data:-&lt;BR /&gt;
&lt;BR /&gt;
2010/06/01 00:00:42 JG Hoover and Candy Web operator1 games 0&lt;BR /&gt;
2010/06/01 00:04:07 JG sasapplication web operator2 games 0&lt;BR /&gt;
2010/06/01 00:04:15 JG Games Sport WEB operator2 games 0&lt;BR /&gt;
2010/06/01 00:35:31 TT BRB Web operator1 music 1&lt;BR /&gt;
&lt;BR /&gt;
How do I write a code in SAS that will read the above data with variables :&lt;BR /&gt;
&lt;BR /&gt;
date (2010/06/01 etc...), content_type(00:00:42 etc...), content_category  (JG and TT) ,download_channel (Hoover and Candy, sasapplication,Gmes Sport,BRB), Games Sport(Web) , operator (operator1, operator2), service (games,music) , successful_download ( 1 or 0 ).&lt;BR /&gt;
&lt;BR /&gt;
Kind Regards,&lt;BR /&gt;
Kritanjli</description>
    <pubDate>Wed, 02 Feb 2011 09:27:45 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2011-02-02T09:27:45Z</dc:date>
    <item>
      <title>Reading SAS data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Reading-SAS-data/m-p/68135#M19510</link>
      <description>Hi All,&lt;BR /&gt;
&lt;BR /&gt;
Many times I get stuck in reading the data files in SAS with variables starting and ending at different positions and I use a long method of making every observation in the data of same length (with length of a variable as maximum length of the observation in that column). If it is required to work on say 1 million of rows then the process becomes almost next to impossible / time consuming. &lt;BR /&gt;
&lt;BR /&gt;
Suppose I have the sample data:-&lt;BR /&gt;
&lt;BR /&gt;
2010/06/01 00:00:42 JG Hoover and Candy Web operator1 games 0&lt;BR /&gt;
2010/06/01 00:04:07 JG sasapplication web operator2 games 0&lt;BR /&gt;
2010/06/01 00:04:15 JG Games Sport WEB operator2 games 0&lt;BR /&gt;
2010/06/01 00:35:31 TT BRB Web operator1 music 1&lt;BR /&gt;
&lt;BR /&gt;
How do I write a code in SAS that will read the above data with variables :&lt;BR /&gt;
&lt;BR /&gt;
date (2010/06/01 etc...), content_type(00:00:42 etc...), content_category  (JG and TT) ,download_channel (Hoover and Candy, sasapplication,Gmes Sport,BRB), Games Sport(Web) , operator (operator1, operator2), service (games,music) , successful_download ( 1 or 0 ).&lt;BR /&gt;
&lt;BR /&gt;
Kind Regards,&lt;BR /&gt;
Kritanjli</description>
      <pubDate>Wed, 02 Feb 2011 09:27:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Reading-SAS-data/m-p/68135#M19510</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-02T09:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: Reading SAS data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Reading-SAS-data/m-p/68136#M19511</link>
      <description>hello,&lt;BR /&gt;
&lt;BR /&gt;
&lt;DIV&gt;you should pass from column/formatted input to list input / modified list input, which is far more flexible.&lt;/DIV&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;DIV&gt;with list input SAS reads a data value until it encounters the delimiter (by default is blank).&lt;/DIV&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;P&gt;anyway with list input default delimiter may cause some troubles if there are variables with embedded blanks (like download_channel in your case), so it may be useful to change the delimiter and then import your data.&lt;/P&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;P&gt;my solution is available for your sample data, but it may not be enough to correctly import the entire file.&lt;/P&gt;&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
data a;&lt;BR /&gt;
&lt;BR /&gt;
infile datalines column=x truncover dsd dlm=' ';*no need for truncover dsd dlm=' ' for this sample data;&lt;BR /&gt;
input date :yymmdd10. content_type :$8. content_category :$2. @;&lt;BR /&gt;
&lt;BR /&gt;
_infile_=reverse(substr(trim(_infile_),x));&lt;BR /&gt;
&lt;BR /&gt;
*list;&lt;BR /&gt;
*put _infile_;&lt;BR /&gt;
&lt;BR /&gt;
input @1 successful_download service $ operator :$9. Games_Sport $ download_channel &amp;amp; :$35.;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
format operator $revers9. service $revers8. Games_Sport $revers8. download_channel $revers35.;&lt;BR /&gt;
&lt;BR /&gt;
datalines;&lt;BR /&gt;
2010/06/01 00:00:42 JG Hoover and Candy Web operator1 games 0&lt;BR /&gt;
2010/06/01 00:04:07 JG sasapplication web operator2 games 0&lt;BR /&gt;
2010/06/01 00:04:15 JG Games Sport WEB operator2 games 0&lt;BR /&gt;
2010/06/01 00:35:31 TT BRB Web operator1 music 1&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;DIV&gt;Marius&lt;/DIV&gt;</description>
      <pubDate>Wed, 02 Feb 2011 11:03:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Reading-SAS-data/m-p/68136#M19511</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-02T11:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: Reading SAS data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Reading-SAS-data/m-p/68137#M19512</link>
      <description>similar challenge at posting &lt;A href="http://support.sas.com/forums/click.jspa?searchID=188615&amp;amp;messageID=49246" target="_blank"&gt;http://support.sas.com/forums/click.jspa?searchID=188615&amp;amp;messageID=49246&lt;/A&gt; is solved by locating the position and length of the column whose length cannot be determined only from a blank delimiter. As here, the call scan() routine can derive the start of the operator column, and the download_channel ends 2 positions before operator starts. The download_channel appears to start in a fixed position (24). So the input operation becomes&lt;BR /&gt;
data loaded(keep= date time content_category download_channel  operator service successful_download ) ;&lt;BR /&gt;
infile 'your input file' lrecl=1000 truncover ;&lt;BR /&gt;
input @ ; *to load infile buffer ;&lt;BR /&gt;
call scan( _infile_, -3, pos, len ) ; * locate POSition of operator column ;&lt;BR /&gt;
chan_len = pos - 24  -1/* for delimiter*/ ; * derive download_channel length ;&lt;BR /&gt;
input date yymmdd10. +1 time time8. +1 content_category $2. +1 download_channel $varying50. chan_len  &lt;BR /&gt;
operator :$20. service :$20. successful_download ;&lt;BR /&gt;
format date yymmdd10.  time time8. ;&lt;BR /&gt;
run ;</description>
      <pubDate>Wed, 02 Feb 2011 14:57:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Reading-SAS-data/m-p/68137#M19512</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-02-02T14:57:02Z</dc:date>
    </item>
  </channel>
</rss>

