01-25-2018 04:26 PM
I have used the following code and macro to import mutliple csv files:
%let path = C:\;
filename folder "&path\ndakota0711";
libname c 'C:\Temp';
length Line 8 county_code $20;
list = dopen('folder');
do Line = 1 to dnum(List);
County_code = trim(dread(List,Line));
drop List Line;
set county_list end=final;
call symputx(cats('County_Code', _N_), trim(County_Code));
call symputx(cats('Name', _N_), trim(nliteral(substr(County_Code,1,min(32, length(County_Code)-4)))));
if final then call symputx(trim('Total'), _N_);
%do i = 1 %to &Total;
proc import datafile="&path\ndakota0711\&&County_Code&i"
However, observations of the first variable "From" in all imported data sets are all trimmed or truncated (I have attached a screenshot of the output file). Can anyone help me with this.
01-25-2018 04:48 PM
When you run PROC IMPORT, check your log. It has the data step to import the code. Modify the lengths/types in that code to be what you want and then use that code to import the data.
This assumes all your data sets have the same type/format. If that's the case you can also follow the approach outlined here to import all at once into the same data set.
Can you tell me where to insert the data step exactly? I am new to SAS and
not very comfortable with it yet. Thanks.
Need further help from the community? Please ask a new question.