У меня есть 10 CSV-файлов, которые я хотел бы сделать PROC IMPORT, по одному в зависимости от значения, введенного пользователем.Например, пользователь введет 201801 для запуска файла CSV за январь 2018 года (PROC IMPORT).
В этом случае я попытался использовать подстроку и период (в которой хранится значение yymmn6., Которое вводил пользователь), а затем оттуда,положить в процедуру импорта.Мой код, как показано ниже:
%let period=201812;
%macro convertdate();
data convertdate;
year=substr("&period",1,4);
month=substr("&period",5,2);
if month='01' then newmonth='jan';
if month='02' then newmonth='feb';
if month='03' then newmonth='mac';
if month='04' then newmonth='apr';
if month='05' then newmonth='may';
if month='06' then newmonth='jun';
if month='07' then newmonth='jul';
if month='08' then newmonth='aug';
if month='09' then newmonth='sep';
if month='10' then newmonth='oct';
if month='11' then newmonth='nov';
if month='12' then newmonth='dec';
run;
/*Assign convertdate the only distinct record into macro, then set as the data step for proc import*/
%if month='01' %then %do;
%let newmonth=jan;
%end;
/*proc import and remaining transformation from existing script*/
proc import out=rmr_raw_source
file="/sasdata/source/user_files/re_&newmonth.2018.xlsx"
dbms=xlsx replace;
sheet="re_&newmonth.2018";
getnames=no;
dbsaslabel=none;
run;
%mend;
%convertdate;
Однако, это не будет работать.Я получаю предупреждение ниже:
ПРЕДУПРЕЖДЕНИЕ: Кажущаяся символьная ссылка NEWMONTH не разрешена.
У кого-нибудь есть лучшее решение?