Hi SAS Users,
I have a problem when trying to run the macro ImportAndTranspose for all files in one folder (named New Folder). The filename is the name of countries with an under space, for example: Argentina_, Austria_, Australia_, Belgium_, US_, UK_,..... and I have 64 files like that.
The code is as below:
filename mydir 'C:\Users\pnguyen\Desktop\New folder';
data _null_;
did = dopen('mydir');
do i = 1 to dnum(did);
fname = dread(did,i);
short_fn= cats(substr(fname, 1,3),'_');
cmd=cats('%ImportAndTranspose(File=C:\Users\pnguyen\Desktop\New folder\',
strip(fname),',outf=',short_fn,'sheet,startsheet=1,endsheet=45);');
call execute(cmd);
end;
keep fname;
run;
Now I just recognize that if I do
short_fn= cats(substr(fname, 1,3),'_');
So, the short_fn for Australia and Austria or Slovakia and Slovenia are the same, but if I did
short_fn= cats(substr(fname, 1,4),'_');
UK_ and US_ do not have enough character in their names, and it make make the results' name in general not aesthetic.
Can you please give me any suggestion to adjust the code to solve the problem?
Many thanks and warm regards.
... View more