<?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: CARDS Cannot Read Lines with 80+ Characters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/CARDS-Cannot-Read-Lines-with-80-Characters/m-p/706518#M216842</link>
    <description>&lt;P&gt;It is because the LRECL for the line is already set too short to hold all of the macro variable.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use PARMCARDS instead.&amp;nbsp; In this code the first data step reads 4 values.&amp;nbsp; The second one reads 24 since the macro variable reference is replaced with 21 copies of xxxx.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options parmcards=text ;
filename text temp;
parmcards;
aaa bbb ccc &amp;amp;mvar
;

%let mvar=xxx;

data test1;
  infile text lrecl=32767 ;
	input @@;
  _infile_=resolve(_infile_);
	input t $ @@;
run;

%let mvar=%sysfunc(repeat(%str(xxxx ),20));

data test2;
  infile text lrecl=32767 ;
	input @@;
  _infile_=resolve(_infile_);
	input t $ @@;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or better still just use PROC STREAM.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 17 Dec 2020 03:59:43 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-12-17T03:59:43Z</dc:date>
    <item>
      <title>CARDS Cannot Read Lines with 80+ Characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CARDS-Cannot-Read-Lines-with-80-Characters/m-p/706071#M216685</link>
      <description>&lt;P&gt;In the following MWE, CARDS is only reading the first 80 characters.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let t=^dji mmm axp amgn aapl ba cat cvx csco ko dow gs hd hon ibm intc jnj jpm mcd mrk msft nke pg crm trv unh vz v wba wmt dis;

data i;
	input @@;
	_infile_=resolve(_infile_);
	input t $ @@;
cards;
^gspc ^irx &amp;amp;t
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Though I am using a macro variable t here, my real code is using a SAS system option -SET to define an environmental variable t instead and using %SYSGET to read it.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2020 18:11:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CARDS-Cannot-Read-Lines-with-80-Characters/m-p/706071#M216685</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2020-12-15T18:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: CARDS Cannot Read Lines with 80+ Characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CARDS-Cannot-Read-Lines-with-80-Characters/m-p/706076#M216689</link>
      <description>&lt;P&gt;It isn't just the length of the line. It is the macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From documentation of macro examples:&lt;/P&gt;
&lt;PRE&gt;
Macro variables are not allowed within the CARDS or DATALINES statements. &lt;BR /&gt;This example shows a trick that uses the RESOLVE function to avoid this limitation. 


Program


%let dog=Golden Retriever;

  data example;
  input text $40.;
    textresolved=dequote(resolve(quote(text)));
  datalines;
  John's &amp;amp;dog
  My &amp;amp;dog is a female
  That's Amy's &amp;amp;dog puppy
  ;

  proc print;
  run;

&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Dec 2020 18:28:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CARDS-Cannot-Read-Lines-with-80-Characters/m-p/706076#M216689</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-12-15T18:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: CARDS Cannot Read Lines with 80+ Characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CARDS-Cannot-Read-Lines-with-80-Characters/m-p/706079#M216691</link>
      <description>&lt;P&gt;I am already using RESOLVE. It seems it's about RESOLVE rather than CARDS or the macro variable since&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data i;
	input @@;
	_infile_=resolve(_infile_);
	input t $ @@;
cards;
^gspc ^irx ^dji mmm axp amgn aapl ba cat cvx csco ko dow gs hd hon ibm intc jnj jpm mcd mrk msft nke pg crm trv unh vz v wba wmt dis
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;still shows the problem while&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data i;
	input t $ @@;
cards;
^gspc ^irx ^dji mmm axp amgn aapl ba cat cvx csco ko dow gs hd hon ibm intc jnj jpm mcd mrk msft nke pg crm trv unh vz v wba wmt dis
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;does not.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2020 18:44:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CARDS-Cannot-Read-Lines-with-80-Characters/m-p/706079#M216691</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2020-12-15T18:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: CARDS Cannot Read Lines with 80+ Characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CARDS-Cannot-Read-Lines-with-80-Characters/m-p/706083#M216692</link>
      <description>&lt;P&gt;You can't change the LRECL of CARDS&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RichardADeVenezia_0-1608058267347.png" style="width: 573px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/52627i08437AB671461366/image-size/large?v=v2&amp;amp;px=999" role="button" title="RichardADeVenezia_0-1608058267347.png" alt="RichardADeVenezia_0-1608058267347.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tricks that run into limitations need new tricks.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can either SCAN through the tokens (presuming you are only parsing out space separated items) or write the value as data in a temporary file and read it back in using INPUT (as might be done if the parsing of the environment variable is more complicated)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let t=^dji mmm axp amgn aapl ba cat cvx csco ko dow gs hd hon ibm intc jnj jpm mcd mrk msft nke pg crm trv unh vz v wba wmt dis;

data want(keep=token);
  length string $1000;
  string = "^gspc ^irx " || symget('t'); * sysget('environment-variable');
  
  do _n_ = 1 to countw(string,' ');
    token = scan(string,_n_,' ');
    output;
  end;
run;


filename sandbox temp;

data _null_;
  file sandbox lrecl=1000;
  put "^gspc ^irx " @@;
  put "&amp;amp;t";
  * put "%sysget('env');
run;

data want;
  infile sandbox lrecl=1000;
  length token $8;
  input token @@;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Dec 2020 18:52:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CARDS-Cannot-Read-Lines-with-80-Characters/m-p/706083#M216692</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-12-15T18:52:05Z</dc:date>
    </item>
    <item>
      <title>Re: CARDS Cannot Read Lines with 80+ Characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CARDS-Cannot-Read-Lines-with-80-Characters/m-p/706517#M216841</link>
      <description>&lt;P&gt;The core problem is that OP wanted to input&amp;nbsp;@@ from the resolved value as _infile_.&amp;nbsp; Thus, the _infile_ length limit makes it infeasible to stuff the &amp;gt;80 character resolved value back into _infile_.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 03:23:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CARDS-Cannot-Read-Lines-with-80-Characters/m-p/706517#M216841</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-12-17T03:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: CARDS Cannot Read Lines with 80+ Characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/CARDS-Cannot-Read-Lines-with-80-Characters/m-p/706518#M216842</link>
      <description>&lt;P&gt;It is because the LRECL for the line is already set too short to hold all of the macro variable.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use PARMCARDS instead.&amp;nbsp; In this code the first data step reads 4 values.&amp;nbsp; The second one reads 24 since the macro variable reference is replaced with 21 copies of xxxx.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options parmcards=text ;
filename text temp;
parmcards;
aaa bbb ccc &amp;amp;mvar
;

%let mvar=xxx;

data test1;
  infile text lrecl=32767 ;
	input @@;
  _infile_=resolve(_infile_);
	input t $ @@;
run;

%let mvar=%sysfunc(repeat(%str(xxxx ),20));

data test2;
  infile text lrecl=32767 ;
	input @@;
  _infile_=resolve(_infile_);
	input t $ @@;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or better still just use PROC STREAM.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 03:59:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/CARDS-Cannot-Read-Lines-with-80-Characters/m-p/706518#M216842</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-12-17T03:59:43Z</dc:date>
    </item>
  </channel>
</rss>

