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 haunt me. Here's the code for my macro which runs without errors %LET PATH = /folders/myfolders/takehometwo;
%LET define_len = SEX RACERPI2 AGE_P ;
LIBNAME new "&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 = &first %to &last;
Filename ZIPFILE SASZIPAM "&PATH/adults&year..zip";
data new.adults&year;
INFILE ZIPFILE(SAMADULT.dat) PAD LRECL=906;
LENGTH &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 &year = 2010
%then input
SAD 372 - 372
NERVOUS 373 - 373 RESTLESS 374 - 374
HOPELESS 375 - 375 EFFORT 376 - 376
WORTHLS 377 - 377;
%else %if &year = 2011
%then input
SAD 264 - 264
NERVOUS 265 - 265 RESTLESS 266 - 266
HOPELESS 267 - 267 EFFORT 268 - 268
WORTHLS 269 - 269;
%else %if &year = 2012
%then input
SAD 330 - 330
NERVOUS 331 - 331 RESTLESS 332 - 332
HOPELESS 333 - 333 EFFORT 334 - 334
WORTHLS 335 - 335;
%else %if &year = 2013
%then input
SAD 1002 - 1002
NERVOUS 1003 - 1003 RESTLESS 1004 - 1004
HOPELESS 1005 - 1005 EFFORT 1006 - 1006
WORTHLS 1007 - 1007;
%else %if &year = 2014
%then input
SAD 1067 - 1067
NERVOUS 1068 - 1068 RESTLESS 1069 - 1069
HOPELESS 1070 - 1070 EFFORT 1071 - 1071
WORTHLS 1072 - 1072;
%else %if &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; When 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 I call any other year I get this error 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. 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? Thank you very much for your time
... View more