DATA Step, Macro, Functions and more

Running a macro - only last results are present

Super Contributor
Posts: 272

Running a macro - only last results are present

[ Edited ]

Dear sir/madam,


I am using the following Macro to convert SAS data sets to SAS xport files to run open cdisc. At the end I see only last one, in this case the VS. In the transport folder, I see name as &xptdata. rather than name of dataset.  Everything else is replaced by previous one. Please help in my code.


%macro xpt_sas (xptdata = );
LIBNAME misc 'C:\Users\ss\Desktop/sas';
libname &xptdata. xport 'C:\Users\ss\Desktop/sasx/&xptdata..xpt';
proc copy in=misc out=&xptdata.;
select &xptdata. ;

%xpt_sas (xptdata = AE); %xpt_sas (xptdata = CM); %xpt_sas (xptdata = CO); %xpt_sas (xptdata = DM); %xpt_sas (xptdata = DS); %xpt_sas (xptdata = EG); %xpt_sas (xptdata = EX); %xpt_sas (xptdata = LB); %xpt_sas (xptdata = MH); %xpt_sas (xptdata = SE); %xpt_sas (xptdata = SUPPAE); %xpt_sas (xptdata = SUPPCM); %xpt_sas (xptdata = SUPPDM); %xpt_sas (xptdata = SUPPDS); %xpt_sas (xptdata = SUPPEG); %xpt_sas (xptdata = SUPPEX); %xpt_sas (xptdata = SUPPLB); %xpt_sas (xptdata = SUPPVS); %xpt_sas (xptdata = SV); %xpt_sas (xptdata = TA); %xpt_sas (xptdata = TE); %xpt_sas (xptdata = TS); %xpt_sas (xptdata = TV); %xpt_sas (xptdata = VS);


Trusted Advisor
Posts: 1,115

Re: base sas

Hi @knveraraju91,


Please use double quotes in the second LIBNAME statement. Single quotes prevent the resolution of macro variable reference &xptdata.

Super Contributor
Posts: 408

Re: base sas

Hi @knveraraju91


It would help a great deal if you could add the SAS log of your program execution. I thuink there are some pointers in there.


For one I think the forward slashes in the pathname of libname misc could be a typo that throws things off. But the log is very important; make it a habit to always include it if you want someone's help.




Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation