Hello, I am trying to run the following code through all the data sets in my work directory (about 3000 files). All of these files begin with "_" (e.g., _01012003, _01022003, etc). Can you please advise on a simple way to rename the fifth variable in all datasets? Currently, each data set looks something like this, named by the date, and the date is included in the fifth variable. (It's the third in this example data set). The x and y variables are not sorted. data _01012003;
input x y mean_01012003;
datalines ;
-117.18604, 32.752861, 29.082
-117.173935, 32.74743, 29.580
-117.116278, 32.744611, 29.580
;
run; The original code I have to import these datafiles is copied below . Maybe there is a way to tweak the original code to rename the 5th variable. %macro impt(fname,path);
proc import DATAFILE="&path" OUT=&fname DBMS=xls REPLACE;
run;
%mend impt;
%let path=D:\User\Data\Output\ap\;
data _null_;
length fname $100;
command = "dir &path.*.xls /b";;
infile dummy pipe filevar=command end=eof truncover filename=fname;
do i = 1 by 1 while(not eof);
input path $128.;
path=catt("&path.",path);
fname = scan(scan(path,-1,'\'),1,'.');
call execute(cats('%nrstr(%impt)(fname=',fname,',path=',path,');'));
end;
stop;
run; The final goal is to have a combined dataset that looks like this: I was having issues with transposing it directly because the variable names did not match and the rows were unsorted. data goal;
input x y mean date;
datalines;
-117.18604, 32.752861, 29.082, 01012003
-117.173935, 32.74743, 29.580, 01012003
-117.116278, 32.744611, 29.580, 01012003
;
run; Thank you.
... View more