<?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 reading in a text file in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36146#M9095</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;DN, you missed something that the OP specified: "I need to read in the data and separate them into different datasets based on the header the are under."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I was hoping that you would look at this as I couldn't remember how to take a character string and apply it to an outfile statement.&amp;nbsp; I got around that by creating a macro variable via proc sql, but I am sure you could come up with something using inputc, putc or the like.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 25 Jul 2011 13:21:04 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2011-07-25T13:21:04Z</dc:date>
    <item>
      <title>Need help with reading in a text file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36139#M9088</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a text file containing data as shown below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ABC&lt;/P&gt;&lt;P&gt;04885423&lt;/P&gt;&lt;P&gt;04886522&lt;/P&gt;&lt;P&gt;048809876&lt;/P&gt;&lt;P&gt;4666324557677879&lt;/P&gt;&lt;P&gt;5754246789532123&lt;/P&gt;&lt;P&gt;DEF&lt;/P&gt;&lt;P&gt;4321234567897654&lt;/P&gt;&lt;P&gt;5434456434565211&lt;/P&gt;&lt;P&gt;GHI&lt;/P&gt;&lt;P&gt;0466643&lt;/P&gt;&lt;P&gt;089876665&lt;/P&gt;&lt;P&gt;0987643349&lt;/P&gt;&lt;P&gt;ABC&lt;/P&gt;&lt;P&gt;097457738&lt;/P&gt;&lt;P&gt;73638933&lt;/P&gt;&lt;P&gt;03988833&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The string 'ABC', 'DEF', and 'GHI' is like a group header.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I need to do is this: &lt;/P&gt;&lt;P&gt;I need to read in the data and separate them into different datasets based on the header the are under.&lt;/P&gt;&lt;P&gt;For example, when i read the 1st header which is 'ABC' the 5 observations under it will be written to a dataset, say data1.&lt;/P&gt;&lt;P&gt;Then when i hit the 2nd header which is 'DEF' the 2 observations under it will be written to another dataset, say data 2.&lt;/P&gt;&lt;P&gt;Same goes for 3rd header.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When i come to the 4th header, which is 'ABC', the observations to be added to dataset data1 if possible. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 01:40:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36139#M9088</guid>
      <dc:creator>ZoeyElle</dc:creator>
      <dc:date>2011-07-25T01:40:01Z</dc:date>
    </item>
    <item>
      <title>Need help with reading in a text file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36140#M9089</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm sure there is a more direct way, but the following will do what I think you are trying to accomplish:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat thedata $20.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input thedata;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;ABC&lt;/P&gt;&lt;P&gt;04885423&lt;/P&gt;&lt;P&gt;04886522&lt;/P&gt;&lt;P&gt;048809876&lt;/P&gt;&lt;P&gt;4666324557677879&lt;/P&gt;&lt;P&gt;5754246789532123&lt;/P&gt;&lt;P&gt;DEF&lt;/P&gt;&lt;P&gt;4321234567897654&lt;/P&gt;&lt;P&gt;5434456434565211&lt;/P&gt;&lt;P&gt;GHI&lt;/P&gt;&lt;P&gt;0466643&lt;/P&gt;&lt;P&gt;089876665&lt;/P&gt;&lt;P&gt;0987643349&lt;/P&gt;&lt;P&gt;ABC&lt;/P&gt;&lt;P&gt;097457738&lt;/P&gt;&lt;P&gt;73638933&lt;/P&gt;&lt;P&gt;03988833&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select distinct thedata&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; into : distinctfiles separated by " "&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from have&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where anyalpha(thedata) gt 0&lt;/P&gt;&lt;P&gt; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select distinct 'if filenm eq "'||strip(thedata)||'" then output '||thedata||";"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; into : ifstmt separated by " "&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from have&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where anyalpha(thedata) gt 0&lt;/P&gt;&lt;P&gt; ;&lt;/P&gt;&lt;P&gt; quit;&lt;/P&gt;&lt;P&gt;data &amp;amp;distinctfiles.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain filenm;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if anyalpha(thedata) then filenm=thedata;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;ifstmt.&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 05:15:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36140#M9089</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-07-25T05:15:16Z</dc:date>
    </item>
    <item>
      <title>Need help with reading in a text file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36141#M9090</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is almost like Art.T 's code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data have;
&amp;nbsp; input thedata $20.;
&amp;nbsp; retain tname;
&amp;nbsp; if anyalpha(thedata) then do; tname=thedata; delete;end;
&amp;nbsp; cards;
ABC
04885423
04886522
048809876
4666324557677879
5754246789532123
DEF
4321234567897654
5434456434565211
GHI
0466643
089876665
0987643349
ABC
097457738
73638933
03988833
;
run;
proc sort data=have;by tname;run;
data _null_;
 declare hash ha (hashexp:10);
&amp;nbsp; ha.definekey('tname','count');
&amp;nbsp; ha.definedata('thedata');
&amp;nbsp; ha.definedone();
&amp;nbsp; do until(last.tname);
&amp;nbsp;&amp;nbsp; set have;
&amp;nbsp;&amp;nbsp; by tname;
&amp;nbsp;&amp;nbsp; count+1;
&amp;nbsp;&amp;nbsp; ha.add();
&amp;nbsp; end;
 ha.output(dataset: tname);
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 08:19:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36141#M9090</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-07-25T08:19:02Z</dc:date>
    </item>
    <item>
      <title>Need help with reading in a text file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36142#M9091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Art,&lt;/P&gt;&lt;P&gt;Thanks for the reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tried the code suggested. I'm hitting some syntax errors. I think because my actual data is more complicated than what i had posted originally. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) some of the headers consist of two words, and some have special characters.&lt;/P&gt;&lt;P&gt;2) some of the data(non header) has alphabets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hit syntax errors for observations that hit above 2 scenarios.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ABC XYZ&lt;/P&gt;&lt;P&gt;04885423&lt;/P&gt;&lt;P&gt;04886522T&lt;/P&gt;&lt;P&gt;0488G09876&lt;/P&gt;&lt;P&gt;4666324557677879&lt;/P&gt;&lt;P&gt;DEF&lt;/P&gt;&lt;P&gt;4321234567897654&lt;/P&gt;&lt;P&gt;5434456434565211&lt;/P&gt;&lt;P&gt;GHI #CVD&lt;/P&gt;&lt;P&gt;0466643&lt;/P&gt;&lt;P&gt;089876665&lt;/P&gt;&lt;P&gt;0987643349&lt;/P&gt;&lt;P&gt;ABC&lt;/P&gt;&lt;P&gt;097457738&lt;/P&gt;&lt;P&gt;73638933&lt;/P&gt;&lt;P&gt;03988833&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would really appreciate your advice.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 09:18:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36142#M9091</guid>
      <dc:creator>ZoeyElle</dc:creator>
      <dc:date>2011-07-25T09:18:43Z</dc:date>
    </item>
    <item>
      <title>Need help with reading in a text file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36143#M9092</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ksharp,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hitting some errors as well, if the headers and observations are more complicated as in my 2nd post.&lt;/P&gt;&lt;P&gt;Would appreciate your advice as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My apologies for not noticing all the patterns of the data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 09:39:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36143#M9092</guid>
      <dc:creator>ZoeyElle</dc:creator>
      <dc:date>2011-07-25T09:39:10Z</dc:date>
    </item>
    <item>
      <title>Need help with reading in a text file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36144#M9093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just add in some conditions to limit what you are looking for and ensure that valid SAS filenames are derived.&amp;nbsp; E.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat thedata $20.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input thedata;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;ABC XYZ&lt;/P&gt;&lt;P&gt;04885423&lt;/P&gt;&lt;P&gt;04886522T&lt;/P&gt;&lt;P&gt;0488G09876&lt;/P&gt;&lt;P&gt;4666324557677879&lt;/P&gt;&lt;P&gt;DEF&lt;/P&gt;&lt;P&gt;4321234567897654&lt;/P&gt;&lt;P&gt;5434456434565211&lt;/P&gt;&lt;P&gt;GHI #CVD&lt;/P&gt;&lt;P&gt;0466643&lt;/P&gt;&lt;P&gt;089876665&lt;/P&gt;&lt;P&gt;0987643349&lt;/P&gt;&lt;P&gt;ABC&lt;/P&gt;&lt;P&gt;097457738&lt;/P&gt;&lt;P&gt;73638933&lt;/P&gt;&lt;P&gt;03988833&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select distinct compress(thedata,,'kdf')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; into : distinctfiles separated by " "&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from have&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where anyalpha(substr(thedata,1,1)) gt 0&lt;/P&gt;&lt;P&gt; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select distinct 'if filenm eq "'||strip(compress(thedata,,'kdf'))||&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; '" then output '||compress(thedata,,'kdf')||";"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; into : ifstmt separated by " "&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from have&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where anyalpha(substr(thedata,1,1)) gt 0&lt;/P&gt;&lt;P&gt; ;&lt;/P&gt;&lt;P&gt; quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data &amp;amp;distinctfiles.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain filenm;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if anyalpha(substr(thedata,1,1)) then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; filenm=compress(thedata,,'kdf');&lt;/P&gt;&lt;P&gt;&amp;nbsp; else do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;ifstmt.&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 11:46:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36144#M9093</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-07-25T11:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with reading in a text file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36145#M9094</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This can all be done in one step.&amp;nbsp; My TEST for "is it a GROUP row" may not be strict enough for your real data.&amp;nbsp; Also,&amp;nbsp; it looks like the data rows may contain more data than a simple string of numbers.&amp;nbsp; If that is the case the ELSE DO can be change to an INPUT statement to read the fields properly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;filename&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; FT15F001 &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;temp&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; groupinput;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;attrib&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; group &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;length&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: teal; font-family: 'Courier New'; background-color: white;"&gt;$20.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;retain&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; group;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;attrib&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; value &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;length&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: teal; font-family: 'Courier New'; background-color: white;"&gt;$64.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;infile&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; FT15F001 &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;truncover&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; @;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; anyalpha(first(_infile_)) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group = _infile_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;delete&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;else&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = _infile_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;parmcards&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;ABC&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;04885423&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;04886522&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;048809876&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;4666324557677879&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;5754246789532123&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;DEF&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;4321234567897654&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;5434456434565211&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;GHI&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;0466643&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;089876665&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;0987643349&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;ABC&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;097457738&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;73638933&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;03988833&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;ABC XYZ&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;04885423&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;04886522T&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;0488G09876&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;4666324557677879&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;DEF&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;4321234567897654&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;5434456434565211&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;GHI #CVD&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;0466643&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;089876665&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;0987643349&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;ABC&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;097457738&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;73638933&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: #ffffc0;"&gt;03988833&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;;;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;print&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 13:06:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36145#M9094</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-07-25T13:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with reading in a text file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36146#M9095</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;DN, you missed something that the OP specified: "I need to read in the data and separate them into different datasets based on the header the are under."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, I was hoping that you would look at this as I couldn't remember how to take a character string and apply it to an outfile statement.&amp;nbsp; I got around that by creating a macro variable via proc sql, but I am sure you could come up with something using inputc, putc or the like.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 13:21:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36146#M9095</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-07-25T13:21:04Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with reading in a text file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36147#M9096</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes I did miss that part about creating separate data sets.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the data are grouped properly then the new data sets could be created in one pass using the HASH method posted by ksharp and my imput method.&amp;nbsp; Some of the group names are not proper MEMBER names.&amp;nbsp; OR if not grouped then sort the output from my program by group and use the HASH.&amp;nbsp; Or the code gen method you posted.&amp;nbsp; Both are adequate for the task we don't have enough info to know which would be better depending on the number of groups or total obs etc. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For your question regarding outfile are you referring to the FILE statement option FILEVAR?&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 13:49:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36147#M9096</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-07-25T13:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with reading in a text file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36148#M9097</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, I was referring to the following scenario:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data &amp;amp;distinctfiles.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain filenm;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if anyalpha(substr(thedata,1,1)) then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; filenm=compress(thedata,,'kdf');&lt;/P&gt;&lt;P&gt;&amp;nbsp; else do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;ifstmt.&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in place of the &amp;amp;ifstmt. that I created in proc sql, how could one specify:&amp;nbsp; output filenm;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 13:55:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36148#M9097</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-07-25T13:55:11Z</dc:date>
    </item>
    <item>
      <title>Need help with reading in a text file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36149#M9098</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; You can't.&amp;nbsp; The OUTPUT statement accepts only name(s) not expressions.&amp;nbsp; You need output METHOD to use expressions and the associated HASH bits.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jul 2011 14:00:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36149#M9098</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-07-25T14:00:24Z</dc:date>
    </item>
    <item>
      <title>Need help with reading in a text file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36150#M9099</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you just need to change&amp;nbsp; the code a little.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data have;
&amp;nbsp; input thedata $20.;
&amp;nbsp; retain tname;
&amp;nbsp; if anyalpha(thedata) eq 1 then do; tname=thedata; delete;end; 
&amp;nbsp; cards;
&amp;nbsp;&amp;nbsp; ABC XYZ
04885423
04886522T
0488G09876
4666324557677879
DEF
4321234567897654
5434456434565211
GHI #CVD
0466643
089876665
0987643349
ABC
097457738
73638933
03988833
;
run;

proc sort data=have;by tname;run;
data _null_;
 declare hash ha (hashexp:10);
&amp;nbsp; ha.definekey('tname','count');
&amp;nbsp; ha.definedata('thedata');
&amp;nbsp; ha.definedone();
&amp;nbsp; do until(last.tname);
&amp;nbsp;&amp;nbsp; set have;
&amp;nbsp;&amp;nbsp; by tname;
&amp;nbsp;&amp;nbsp; count+1;
&amp;nbsp;&amp;nbsp; ha.add();
&amp;nbsp; end;
 ha.output(dataset: scan(tname,1)||strip(count));
run;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jul 2011 04:04:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Need-help-with-reading-in-a-text-file/m-p/36150#M9099</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-07-26T04:04:54Z</dc:date>
    </item>
  </channel>
</rss>

