Hi SAS Users,
Today I ran a macro,
%macro ImportAndTranspose(
File=
, cur=
, outf=
, StartSheet=
, EndSheet=
);
I have the mprint code is as below:
MPRINT(IMPORTANDTRANSPOSE): proc import datafile= "C:\Users\pnguyen\Desktop\New folder\United KingdomEUR" out= United
Kingdom_sheet1 dbms= xlsx replace;
MPRINT(IMPORTANDTRANSPOSE): range= "Sheet1$A:X";
MPRINT(IMPORTANDTRANSPOSE): getnames= yes;
MPRINT(IMPORTANDTRANSPOSE): run;
It seems that there is no abnormal thing can be seen by me from such a code. However, when running, there is a problem popping up:
1 + proc import datafile= "C:\Users\pnguyen\Desktop\New folder\United KingdomEUR" out= United
1 !+Kingdom_sheet1 dbms= xlsx replace; range= "Sheet1$A:X";
______________
22
202
1 !+getnames= yes; run;
ERROR 22-322: Syntax error, expecting one of the following: ;, (, DATAFILE, DATATABLE, DBMS, DEBUG, FILE, OUT, REPLACE, TABLE,
_DEBUG_.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
NOTE: Line generated by the CALL EXECUTE routine.
2 + proc sort data= United Kingdom_sheet1; by Type; run;
______________
22
202
ERROR 22-322: Syntax error, expecting one of the following: ;, (, ASCII, BUFFNO, DANISH, DATA, DATECOPY, DETAILS, DIAG, DUPOUT,
EBCDIC, EQUALS, FINNISH, FORCE, IN, ISA, L, LEAVE, LIST, MESSAGE, MSG, NATIONAL, NODUP, NODUPKEY, NODUPKEYS,
NODUPLICATE, NODUPLICATES, NODUPREC, NODUPRECS, NODUPS, NOEQUALS, NORWEGIAN, NOTHREADS, NOUNIKEY, NOUNIKEYS,
NOUNIQUEKEY, NOUNIQUEKEYS, NOUNIQUEREC, NOUNIQUERECS, NOUNIREC, NOUNIRECS, OSA, OUT, OVERWRITE, PAGESIZE, PRESORTED,
PSIZE, REVERSE, SIZE, SORTSEQ, SORTSIZE, SORTWKNO, SWEDISH, T, TAGSORT, TECH, TECHNIQUE, TESTHSI, THREADS, UNIOUT,
UNIQUEOUT, WKNO, WORKNO.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
I guess the problem popping up because of the blank in the middle of the out data but I do not know how to deal with it, It seems to me no problem here. It is how I get my input for such a macro, including the outf.
filename mydir 'C:\Users\pnguyen\Desktop\New folder';
data _null_;
did = dopen('mydir');
do i = 1 to dnum(did);
fname = scan(dread(did,i),1,'.');
/*fname: United KingdomGBP*/
length short_fn $29 currency $3 ;
short_fn= cats(substr(fname, 1,length(fname)-3),'_');
currency=substr(fname,length(fname)-2);
cmd=cats('%ImportAndTranspose(File=C:\Users\pnguyen\Desktop\New folder\',
strip(fname),
',cur=',currency,
',outf=',short_fn,'sheet,startsheet=1,endsheet=45);');
call execute(cmd);
end;
keep fname;
run;
I do not post my full code here that I do not want to confuse you, but it is the code 1 from this topic
https://communities.sas.com/t5/SAS-Programming/Substitute-codes-generating-different-results-debug/m-p/714815#M220724
Thank you and warm regards!
P/S: I want to keep the name "United Kingdom" rather than delete the blank in the middle or put a under space because it relates to my following purposes.
... View more