<?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: Need help with importing data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing-data/m-p/407700#M99367</link>
    <description>&lt;P&gt;No it goes like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Raw data:&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;A123456789,A,3&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1,Y,15Feb1960,M,M,3,FT,55000&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2,N,3Jun1965,F,M,3,UE,0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Desired output:&lt;/U&gt;&lt;BR /&gt;&lt;STRONG&gt;A123456789 A 3&lt;/STRONG&gt; 1 Y 15Feb1960 M M 3 FT 55000&lt;BR /&gt;&lt;STRONG&gt;A123456789 A 3&lt;/STRONG&gt; 2 N 3Jun1965 F M 3 UE 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first three columns are "header" columns and they should retain to the next line for some of the rows.&lt;/P&gt;</description>
    <pubDate>Thu, 26 Oct 2017 15:54:19 GMT</pubDate>
    <dc:creator>kisumsam</dc:creator>
    <dc:date>2017-10-26T15:54:19Z</dc:date>
    <item>
      <title>Need help with importing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing-data/m-p/407680#M99360</link>
      <description>&lt;P&gt;I'm trying to read in this set of data and I need some help:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A123456789,A,3&lt;BR /&gt;1,Y,15Feb1960,M,M,3,FT,55000&lt;BR /&gt;2,N,3Jun1965,F,M,3,UE,0&lt;BR /&gt;A135790234,B,1&lt;BR /&gt;1,Y,19Oct1944,F,D,0,NA,3000&lt;BR /&gt;B234523456,A,2&lt;BR /&gt;1,Y,30Jun1978,F,M,1,PT,4000&lt;BR /&gt;2,N,21May1975,M,M,2,FT,30000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need the output to look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image 12.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16235iD4D6A182DA8692DA/image-size/large?v=v2&amp;amp;px=999" role="button" title="image 12.png" alt="image 12.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have come up with this solution which works fine:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Yourdata (drop=temp);
Infile datalines dsd;
retain var1-var3;
input temp : $10. @;
if length(temp) ^= 1 then do;
Input @1 var1 $10.
      @12 var2 $
      var3 $
      var4
      var5 $
      var6 : date9.
      var7 $
      var8 $
      var9
      var10 $
      var11 ;
end; else do;
Input @1 var4
      var5 $
      var6 : date9.
      var7 $
      var8 $
      var9
      var10 $
      var11 ;
end;
format var6 date9.;
datalines;
A123456789,A,3
1,Y,15Feb1960,M,M,3,FT,55000
2,N,3Jun1965,F,M,3,UE,0
A135790234,B,1
1,Y,19Oct1944,F,D,0,NA,3000
B234523456,A,2
1,Y,30Jun1978,F,M,1,PT,4000
2,N,21May1975,M,M,2,FT,30000
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, I'm partially using formatted input instead of list input and I'm ignoring the delimiter for some of the columns. I am wondering if there is a better solution for this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help? Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 15:34:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing-data/m-p/407680#M99360</guid>
      <dc:creator>kisumsam</dc:creator>
      <dc:date>2017-10-26T15:34:30Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with importing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing-data/m-p/407683#M99361</link>
      <description>&lt;P&gt;Assuming your input data is in a consistent format, that is - always 3 lines and all variables exist (even if some of them have missing value)&amp;nbsp;then you can read the 3 lines with one INPUT staement, in a format of:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  input
    &amp;lt;first line variables&amp;gt; /
    &amp;lt;second line variables&amp;gt; /
    &amp;lt;third line variables&amp;gt;
 ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The slash (/) tells sas to continue reading from next line.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 15:31:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing-data/m-p/407683#M99361</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-10-26T15:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with importing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing-data/m-p/407686#M99362</link>
      <description>Allso add option dlm=',' to the infile staement:&lt;BR /&gt;Infile datalines dsd dlm=',';</description>
      <pubDate>Thu, 26 Oct 2017 15:34:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing-data/m-p/407686#M99362</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-10-26T15:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with importing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing-data/m-p/407689#M99363</link>
      <description>&lt;P&gt;No unfortunately I need the first three columns to "retain" to the next line for some of the rows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image 13.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16236i747F878ACE05BA56/image-size/large?v=v2&amp;amp;px=999" role="button" title="image 13.png" alt="image 13.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't think the slashes would work. Also, the DSD option already changes the delimiter to a comma. I don't think the DLM="," option is needed...&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 15:38:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing-data/m-p/407689#M99363</guid>
      <dc:creator>kisumsam</dc:creator>
      <dc:date>2017-10-26T15:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with importing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing-data/m-p/407696#M99366</link>
      <description>&lt;P&gt;OK, I see - you have a prefix line to concatenate with next one or more lines,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;where each of them - except the prefix line - creates an output observation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then your code is perfct. I wouldn't change it.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 15:56:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing-data/m-p/407696#M99366</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-10-26T15:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with importing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing-data/m-p/407700#M99367</link>
      <description>&lt;P&gt;No it goes like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Raw data:&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;A123456789,A,3&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1,Y,15Feb1960,M,M,3,FT,55000&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2,N,3Jun1965,F,M,3,UE,0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Desired output:&lt;/U&gt;&lt;BR /&gt;&lt;STRONG&gt;A123456789 A 3&lt;/STRONG&gt; 1 Y 15Feb1960 M M 3 FT 55000&lt;BR /&gt;&lt;STRONG&gt;A123456789 A 3&lt;/STRONG&gt; 2 N 3Jun1965 F M 3 UE 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first three columns are "header" columns and they should retain to the next line for some of the rows.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 15:54:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing-data/m-p/407700#M99367</guid>
      <dc:creator>kisumsam</dc:creator>
      <dc:date>2017-10-26T15:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with importing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing-data/m-p/407706#M99368</link>
      <description>&lt;P&gt;That's correct &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't like the fact that some columns are read in using formatted input when the data are separated by a comma:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Input &lt;FONT color="#FF0000"&gt;@1&lt;/FONT&gt; var1 $10.
      &lt;FONT color="#FF0000"&gt;@12&lt;/FONT&gt; var2 $
      var3 $
      var4&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The VAR1 column had to be re-read" in since I had the TEMP column there. Re-reading data cannot be done using list input and the only solution I can think of is to use the formatted input.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just curious if there is a better way around...&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 16:08:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing-data/m-p/407706#M99368</guid>
      <dc:creator>kisumsam</dc:creator>
      <dc:date>2017-10-26T16:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with importing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing-data/m-p/407752#M99372</link>
      <description>&lt;P&gt;Here is one possible alternative:&lt;/P&gt;
&lt;PRE&gt;Data Yourdata;
  infile datalines dsd delimiter=',';
  informat var1 $10.;
  informat var2 var3 $1.;
  informat var4 8.;
  informat var5 $1.;
  informat var6 date9.;
  informat var7 var8 $1.;
  informat var9 8.;
  informat var10 $2.;
  informat var11 8.;
  retain var1-var3;
  input @;
  if length(scan(_infile_,1,',')) ^= 1 then do;
    Input var1
          var2
          var3;
  end;
  else do;
    input var4
      var5
      var6
      var7
      var8
      var9
      var10
      var11 ;
    output;
  end;
  format var6 date9.;
  datalines;
A123456789,A,3
1,Y,15Feb1960,M,M,3,FT,55000
2,N,3Jun1965,F,M,3,UE,0
A135790234,B,1
1,Y,19Oct1944,F,D,0,NA,3000
B234523456,A,2
1,Y,30Jun1978,F,M,1,PT,4000
2,N,21May1975,M,M,2,FT,30000
;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 17:54:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing-data/m-p/407752#M99372</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-10-26T17:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with importing data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing-data/m-p/407764#M99378</link>
      <description>Awesome! That's exactly what I was looking for. Thanks!</description>
      <pubDate>Thu, 26 Oct 2017 18:13:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-importing-data/m-p/407764#M99378</guid>
      <dc:creator>kisumsam</dc:creator>
      <dc:date>2017-10-26T18:13:40Z</dc:date>
    </item>
  </channel>
</rss>

