<?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: Datalines Input in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Datalines-Input/m-p/558982#M156053</link>
    <description>No, the number of lines will vary.  And if you read my latest reply I hit a new wrinkle that leaves me wondering if I can do this task at all using DATALINES.</description>
    <pubDate>Wed, 15 May 2019 14:52:06 GMT</pubDate>
    <dc:creator>buechler66</dc:creator>
    <dc:date>2019-05-15T14:52:06Z</dc:date>
    <item>
      <title>Datalines Input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datalines-Input/m-p/558892#M156011</link>
      <description>&lt;P&gt;Hi.&amp;nbsp; I'm trying to read in the following 3 lines into a single variable named 'SELECT'.&amp;nbsp; So as each line is read in from the DATALINES statement I'm trying to append the lines together.&amp;nbsp; But I cannot seem to get this to work.&amp;nbsp; This is code I've been playing with, but it's not working.&amp;nbsp; I'd love some help if you have time.&amp;nbsp; Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA SELECT;&lt;BR /&gt;INFILE datalines TRUNCOVER;&lt;BR /&gt;INPUT SELECT $;&lt;BR /&gt;DATALINES;&lt;BR /&gt;SELECT DISTINCT &lt;BR /&gt;NAME&lt;BR /&gt;,ADDRESS&lt;BR /&gt;;&lt;BR /&gt;RETAIN SELECT;&lt;BR /&gt;LENGTH SELECT $32767;&lt;BR /&gt;CALL MISSING(SELECT);&lt;BR /&gt;SELECT=CATX(' ',SELECT,_INFILE_);&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The desired output would be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;SELECT&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;SELECT DISTINCT&amp;nbsp;NAME&amp;nbsp;,ADDRESS&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 13:03:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datalines-Input/m-p/558892#M156011</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2019-05-15T13:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: Datalines Input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datalines-Input/m-p/558905#M156016</link>
      <description>&lt;P&gt;Why do you have lines of code after your data step? Where you trying to run do this in two data steps?&amp;nbsp; If so you need a new data statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't overwrite your value. You can use the INPUT statement without any variables to give your program access to the _INFILE_ variable.&amp;nbsp; Normally you would use the END= option on the INFILE statement to indicate a variable that you could test so you could output only at the end of the input. But that does not work with in-line data.&amp;nbsp; So instead you can use the EOF= option which is used to point to label location in your code that should run when the end of the input data is reached.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA SELECT;
  INFILE datalines eof=write;
  length select $32767 ;&lt;BR /&gt;  retain select;
  input;
  select=catx(' ',select,_infile_);
return;
write: output;
DATALINES;
SELECT DISTINCT 
NAME
,ADDRESS
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 13:19:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datalines-Input/m-p/558905#M156016</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-15T13:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: Datalines Input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datalines-Input/m-p/558912#M156019</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;AArgh - 7 minutes to late .. &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;Hi&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I have changed a few things - but this seems to work ..&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Basically the "Input SELECT $;" statement would replace the accumulated contents with the contents of _INFILE_ , so i have&amp;nbsp; removed that part of the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also the output has to be controlled for only 1 observation in the output table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Henrik&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA SELECT;&lt;BR /&gt;INFILE datalines TRUNCOVER EOF=EOF;&lt;BR /&gt;LENGTH SELECT $32767;&lt;BR /&gt;INPUT ;&lt;BR /&gt;RETAIN SELECT;&lt;BR /&gt;SELECT=CATX(' ',SELECT,_INFILE_);&lt;BR /&gt;put select= ; * demo / debugging only ;&lt;BR /&gt;RETURN;&lt;BR /&gt;EOF: OUTPUT;&lt;BR /&gt;RETURN;&lt;BR /&gt;DATALINES;&lt;BR /&gt;SELECT DISTINCT &lt;BR /&gt;NAME&lt;BR /&gt;,ADDRESS&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 13:27:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datalines-Input/m-p/558912#M156019</guid>
      <dc:creator>HenrikDorf</dc:creator>
      <dc:date>2019-05-15T13:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: Datalines Input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datalines-Input/m-p/558972#M156047</link>
      <description>&lt;P&gt;Wow.&amp;nbsp; Thank you so much.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That worked, but perhaps I should've provided my entire Datalines for input.&amp;nbsp; Ultimately I'm hoping to read-in an entire Proc SQL query.&amp;nbsp; But it appears that the semicolons in the query are going to mess up the Datalines statement.&amp;nbsp; For example if you look at the first DATALINE that is input - it ends with a semicolon and I think that breaks the program.&amp;nbsp; Is there any work-around for this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA SELECT;
  INFILE datalines eof=write;
  length select $32767 ;  retain select;
  input;
  select=catx(' ',select,_infile_);
return;
write: output;
DATALINES;
PROC SQL;
SELECT DISTINCT 
		CLM.BENE_SK
		,1 as card
FROM	OPI_AAL.CLM AS CLM
INNER JOIN NFPP_TRD.&amp;amp;SYSUSERID._HHASWITCH_CLMS AS HHACLMS
	ON CLM.BENE_SK = HHACLMS.BENE_SK
WHERE (CLM.CLM_FROM_DT BETWEEN &amp;amp;bgn_dt AND &amp;amp;end_dt) 
	AND (CLM.CLM_PRNCPL_DGNS_CD LIKE 'I50%' or CLM.CLM_DGNS_1_CD LIKE 'I50%' or CLM.CLM_DGNS_2_CD LIKE 'I50%' 
     			or CLM.CLM_DGNS_3_CD LIKE 'I50%' or CLM.CLM_DGNS_4_CD LIKE 'I50%' or CLM.CLM_DGNS_5_CD LIKE 'I50%' 
				or CLM.CLM_DGNS_6_CD LIKE 'I50%' or CLM.CLM_DGNS_7_CD LIKE 'I50%' or CLM.CLM_DGNS_8_CD LIKE 'I50%')
	AND CLM.CLM_FINL_ACTN_IND = 'Y'
	AND CLM.CLM_TYPE_CD BETWEEN 2000 AND 2999
order by BENE_SK
;QUIT;

;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 May 2019 14:45:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datalines-Input/m-p/558972#M156047</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2019-05-15T14:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: Datalines Input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datalines-Input/m-p/558975#M156049</link>
      <description>&lt;P&gt;Is the actual data you are going to read &lt;STRONG&gt;always&lt;/STRONG&gt; going to read &lt;STRONG&gt;exactly &lt;/STRONG&gt;3 lines of data?&lt;/P&gt;
&lt;P&gt;The read the values in one pass:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;DATA SELECT;
   INFILE datalines TRUNCOVER;
   informat v1 v2 v3 $25.;
   INPUT v1 1-25
    / v2 1-25
    / v3 1-25
   ;
   length select $ 75;
   select= catx(' ',v1,v2,v3);
   /* drop v1 v2 v3;*/
DATALINES;
SELECT DISTINCT 
NAME
,ADDRESS
;&lt;/PRE&gt;
&lt;P&gt;I explicitly read columns 1 to 25 in the example because things like Name and Address often have spaces and such so that your list style input would only read the first word. Adjust lengths as need. The / in the input says in effect "go to the next line and read"&lt;/P&gt;
&lt;P&gt;I would suggest examining your data and determining if a length of $32767 is actually needed though.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 14:48:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datalines-Input/m-p/558975#M156049</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-15T14:48:39Z</dc:date>
    </item>
    <item>
      <title>Re: Datalines Input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datalines-Input/m-p/558982#M156053</link>
      <description>No, the number of lines will vary.  And if you read my latest reply I hit a new wrinkle that leaves me wondering if I can do this task at all using DATALINES.</description>
      <pubDate>Wed, 15 May 2019 14:52:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datalines-Input/m-p/558982#M156053</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2019-05-15T14:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: Datalines Input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datalines-Input/m-p/558983#M156054</link>
      <description>&lt;P&gt;If the in-line data contains semi-colons you can handle that by telling SAS to look for four semi-colons to mark the end of the in-line data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;datalines4;
blah blah; blah blah;
;;;;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Or better still just store the code to be read in a separate file instead of using in-line data.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 14:53:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datalines-Input/m-p/558983#M156054</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-15T14:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: Datalines Input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datalines-Input/m-p/559028#M156067</link>
      <description>Thanks so much for your help. I really appreciate you taking the time to help.</description>
      <pubDate>Wed, 15 May 2019 15:43:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datalines-Input/m-p/559028#M156067</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2019-05-15T15:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: Datalines Input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Datalines-Input/m-p/559048#M156071</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/79805"&gt;@buechler66&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;No, the number of lines will vary. And if you read my latest reply I hit a new wrinkle that leaves me wondering if I can do this task at all using DATALINES.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Crossed time. Your post of your actual problem was not there when I posted by my response.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why datalines at all? Read a text file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And from the character count of some of the code I see on this forum I'm not sure I would expect every single Proc Sql call to fit into a single variable to begin with.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2019 16:17:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Datalines-Input/m-p/559048#M156071</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-15T16:17:55Z</dc:date>
    </item>
  </channel>
</rss>

