Hi, Unfortunately I have a rather non user friendly data structure. It consists of 200 txt files (dlm = ',') that have to be concatenated. Each files has +/- 2 observations and 453 variables. I have written some code to read the 200 data files like this: %symdel start eind;
%let start=1;
%let eind=9;
%macro loop_attr_2017_10;
%let i=&start;
%do %while (&i <= &eind );
proc import datafile="$FSROOT/.../attributes.long.55769e3d9a318c4312000009.csv/part-0000&i."
out=attr_2017_&i.
dbms=dlm
replace; DELIMITER = ',';
getnames=yes;
GUESSINGROWS=2147483647;
run;
%let i=%eval(&i+1);
%end;
%mend;
%loop_attr_2017_10; After I have read the data, I want to concatenate the 200 files (attr_2017_0 -> attr_2017_199) to one file (attributes_2017). data attributes_2017;
set ATTR_2017_0;
run;
%let conBegin=1;
%let conEind=199;
%macro concet_attr_2017;
%let i = &conBegin;
%do %while (&i <= &conEind);
data attributes_2017;
set attributes_2017 attr_2017_&i.;
run;
%let i=%eval(&i+1);
%end;
%mend;
%concet_attr_2017; But this is where the troubles arise. For some files , some values of the 453 variables are missing for all the subjects in that file. So SAS will read that variable by default as a character. But, when in the next file the value is not missing and it is a numeric variable, it becomes impossible to concatenate the two files. ERROR: Variable activity_first_time_value has been defined as both character and numeric. For example 'activity_first_time_value' in the file 'ATTR_2017_3' is characteristic, while in 'ATTR_2017_4' it is numeric. Since I have 453 variables and 200 files to concatenate, it is too much work to account for it individually. So my question is; is there a way the program this concatenate is such a way that whenever SAS detects in the next file the variables as numeric, the variable in the previous file is also changed into numeric? Or another work around? Thanks in advance! Kind Regards, Leonard PS: I also consulted this page, but as mentioned before, I believe there a too much variables to account for it manually.
... View more