<?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: Invalid Data Length Error while reading data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Invalid-Data-Length-Error-while-reading-data/m-p/642899#M191848</link>
    <description>&lt;P&gt;Why are you using&amp;nbsp;SASZIPAM engine instead of the ZIP engine?&lt;/P&gt;
&lt;P&gt;Are you sure that your ZIP file is valid?&amp;nbsp; Can you read it with a normal utility?&lt;/P&gt;</description>
    <pubDate>Sat, 25 Apr 2020 16:42:58 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-04-25T16:42:58Z</dc:date>
    <item>
      <title>Invalid Data Length Error while reading data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-Data-Length-Error-while-reading-data/m-p/642898#M191847</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi, im in a class in university where I am learning to use SAS. I am trying to read data from a zipped file using a macro, and then labelling the data. I am using SAS Studio on a mac. I thought I had resolved this error yesterday but it has come back to&amp;nbsp;haunt me.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here's the code for my macro which runs without errors&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;%LET PATH = /folders/myfolders/takehometwo;
%LET define_len = SEX  RACERPI2  AGE_P ;   
LIBNAME new "&amp;amp;PATH";
* Step 2;
* Define the MACRO, it will unzip the file then label the 
  variables depending on which year the dataset represents;
%MACRO createset (first = , last = );
%do year = &amp;amp;first %to &amp;amp;last;   
	Filename ZIPFILE SASZIPAM "&amp;amp;PATH/adults&amp;amp;year..zip";
	data new.adults&amp;amp;year;
	INFILE ZIPFILE(SAMADULT.dat)  PAD LRECL=906;
	LENGTH &amp;amp;define_len 3;
	* Input for each column for emotions the datasets vary;
	input 
	 	RECTYPE       1 -   2   /* File type identifier */ 
	 	SRVY_YR       3 -   6   /* Survey year */
	 	HHX		$	  7 -  12
	 	FMX		$	 16 -  17
	 	FPX		$	 18 -  19
	 	WTFA_SA      27 -  32   /* Final weight */
		STRAT_P      34 -  36   /* Pseudo-stratum for PUF variance estimation */
		PSU_P        37 -  38   /* Pseudo-PSU for PUF estimation */
	        SEX          39
		RACERPI2     42 -  43   /* OMB groups w/multiple race */
		AGE_P        48 -  49 @; /* Age reported */
		%if &amp;amp;year = 2010
		%then input  
		  SAD         372 - 372
	      NERVOUS     373 - 373    RESTLESS    374 - 374
	      HOPELESS    375 - 375    EFFORT      376 - 376
	      WORTHLS     377 - 377;
	 	%else %if &amp;amp;year = 2011 
	 	%then input
		  SAD         264 - 264
	      NERVOUS     265 - 265    RESTLESS    266 - 266
	      HOPELESS    267 - 267    EFFORT      268 - 268
	      WORTHLS     269 - 269;
	    %else %if &amp;amp;year = 2012 
	 	%then input
		  SAD         330 - 330
	      NERVOUS     331 - 331    RESTLESS    332 - 332
	      HOPELESS    333 - 333    EFFORT      334 - 334
	      WORTHLS     335 - 335;
	    %else %if &amp;amp;year = 2013 
	 	%then input
		  SAD         1002 - 1002
	      NERVOUS     1003 - 1003    RESTLESS    1004 - 1004
	      HOPELESS    1005 - 1005    EFFORT      1006 - 1006
	      WORTHLS     1007 - 1007;
	    %else %if &amp;amp;year = 2014 
	 	%then input
		  SAD         1067 - 1067
	      NERVOUS     1068 - 1068    RESTLESS    1069 - 1069
	      HOPELESS    1070 - 1070    EFFORT      1071 - 1071
	      WORTHLS     1072 - 1072;
	    %else %if &amp;amp;year = 2015 
	 	%then input
		  SAD         884 - 884
	      NERVOUS     885 - 885    RESTLESS    886 - 886
	      HOPELESS    887 - 887    EFFORT      888 - 888
	      WORTHLS     889 - 889
		;
run;
%end;
%mend createset;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;When&amp;nbsp;I call the macro for just the years 2010 and 2011 it doesnt give me any errors at all, but the 2010 dataset is a little strange. When&amp;nbsp;I call any other year&amp;nbsp;I get this error&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt; 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         %createset(first=2010, last=2015);
 
 NOTE: The infile library ZIPFILE is:
       Stream=/folders/myfolders/takehometwo/adults2011.zip
 
 NOTE: The infile ZIPFILE(SAMADULT.dat) is:
       File Name=SAMADULT.dat,
       Compressed Size=3125461,
       Uncompressed Size=27368606,
       Compression Level=-1,Clear Text=Yes
 
 NOTE: A total of 33014 records were read from the infile library ZIPFILE.
 NOTE: 33014 records were read from the infile ZIPFILE(SAMADULT.dat).
 NOTE: The data set NEW.ADULTS2010 has 33014 observations and 18 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.45 seconds
       cpu time            0.35 seconds
       
 
 
 NOTE: The infile library ZIPFILE is:
       Stream=/folders/myfolders/takehometwo/adults2012.zip
 
 NOTE: The infile ZIPFILE(SAMADULT.dat) is:
       File Name=SAMADULT.dat,
       Compressed Size=4379069,
       Uncompressed Size=37563200,
       Compression Level=-1,Clear Text=No
 
 ERROR: Invalid data length.
 FATAL: Unrecoverable I/O error detected in the execution of the DATA step program.  Aborted during the INITIALIZE EXECUTION phase.
 NOTE: The SAS System stopped processing this step because of errors.
 WARNING: The data set NEW.ADULTS2011 may be incomplete.  When this step was stopped there were 0 observations and 18 variables.
 WARNING: Data set NEW.ADULTS2011 was not replaced because this step was stopped.
 NOTE: DATA statement used (Total process time):
       real time           0.03 seconds
       cpu time            0.02 seconds
       
 
 
 ERROR: Member SAMADULT.dat does not exist.
 NOTE: The SAS System stopped processing this step because of errors.
 WARNING: The data set NEW.ADULTS2012 may be incomplete.  When this step was stopped there were 0 observations and 18 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.04 seconds
       cpu time            0.02 seconds
       
 
 
 ERROR: Member SAMADULT.dat does not exist.
 NOTE: The SAS System stopped processing this step because of errors.
 WARNING: The data set NEW.ADULTS2013 may be incomplete.  When this step was stopped there were 0 observations and 18 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.03 seconds
       cpu time            0.01 seconds
       
 
 
 NOTE: The infile library ZIPFILE is:
       Stream=/folders/myfolders/takehometwo/adults2015.zip
 
 NOTE: The infile ZIPFILE(SAMADULT.dat) is:
       File Name=SAMADULT.dat,
       Compressed Size=451,Uncompressed Size=904,
       Compression Level=-1,Clear Text=No
 
 ERROR: Invalid data length.
 FATAL: Unrecoverable I/O error detected in the execution of the DATA step program.  Aborted during the INITIALIZE EXECUTION phase.
 NOTE: The SAS System stopped processing this step because of errors.
 WARNING: The data set NEW.ADULTS2014 may be incomplete.  When this step was stopped there were 0 observations and 18 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.05 seconds
       cpu time            0.02 seconds
       
 
 74         
 75         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 ERROR: Invalid data length.
 FATAL: Unrecoverable I/O error detected in the execution of the DATA step program.  Aborted during the INITIALIZE EXECUTION phase.
 WARNING: The data set NEW.ADULTS2015 may be incomplete.  When this step was stopped there were 0 observations and 18 variables.&lt;/PRE&gt;&lt;P&gt;Is this maybe because the .dat files in the zip are all called the same thing, so when it unzips the second one it gets called something like SAMADULT 2.zip?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your time&lt;/P&gt;</description>
      <pubDate>Sat, 25 Apr 2020 16:40:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-Data-Length-Error-while-reading-data/m-p/642898#M191847</guid>
      <dc:creator>romonysh</dc:creator>
      <dc:date>2020-04-25T16:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Data Length Error while reading data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-Data-Length-Error-while-reading-data/m-p/642899#M191848</link>
      <description>&lt;P&gt;Why are you using&amp;nbsp;SASZIPAM engine instead of the ZIP engine?&lt;/P&gt;
&lt;P&gt;Are you sure that your ZIP file is valid?&amp;nbsp; Can you read it with a normal utility?&lt;/P&gt;</description>
      <pubDate>Sat, 25 Apr 2020 16:42:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-Data-Length-Error-while-reading-data/m-p/642899#M191848</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-25T16:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Data Length Error while reading data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-Data-Length-Error-while-reading-data/m-p/642913#M191849</link>
      <description>&lt;P&gt;Thats a question I didnt ask myself. ZIP works a lot better than SASZIPAM. I no longer get any errors, and for some reason my adults2014 dataset is empty. I also am getting missing values for the emotion slots but the errors are gone for now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Sat, 25 Apr 2020 17:18:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-Data-Length-Error-while-reading-data/m-p/642913#M191849</guid>
      <dc:creator>romonysh</dc:creator>
      <dc:date>2020-04-25T17:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Data Length Error while reading data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Invalid-Data-Length-Error-while-reading-data/m-p/642926#M191855</link>
      <description>&lt;P&gt;Make sure your macro is generating valid SAS code.&lt;/P&gt;
&lt;P&gt;You seem to have missing semi-colons.&lt;/P&gt;
&lt;P&gt;In a statement like this&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;x=1 %then input a b c;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the semi-colon ends the %IF/%THEN block. But the INPUT statement needs its own semi-colon.&lt;/P&gt;</description>
      <pubDate>Sat, 25 Apr 2020 18:30:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Invalid-Data-Length-Error-while-reading-data/m-p/642926#M191855</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-25T18:30:29Z</dc:date>
    </item>
  </channel>
</rss>

