Help using Base SAS procedures

Importing by using macro

Reply
N/A
Posts: 0

Importing by using macro

i have aimport code how can i keep it in macro and reuse it the code is here now i want to change the outfile and datafile only by using macro.


PROC IMPORT OUT= WORK.ASd
DATAFILE= "C:\Documents and Settings\Ma
r\dq_sample.xls"
DBMS=EXCEL5 REPLACE;
GETNAMES=YES;
RUN;
Super Contributor
Super Contributor
Posts: 3,174

Re: Importing by using macro

Macros are executed, optionally with macro variable substition on the command line. Then, the macro variable reference is made using a &varname, as shown below:

%MACRO MYMACRO(MYVAR);
%PUT MYVAR IS SUBSTITUTED AS: &MYVAR;
%MEND MYMACRO;
%MYMACRO(some_value);

Refer to the SAS Macro Language documentation at the SAS support website http://support.sas.com/ and the DOC web page:

http://support.sas.com/documentation/onlinedoc/91pdf/index.html


http://support.sas.com/onlinedoc/913/getDoc/en/mcrolref.hlp/a002293969.htm


Scott Barry
SBBWorks, Inc.
N/A
Posts: 0

Re: Importing by using macro

%macro import(output=,path=);
PROC IMPORT OUT= &output
DATAFILE= "&path"
DBMS=DLM REPLACE;
DELIMITER='7C'x;
GETNAMES=YES;
DATAROW=2;
RUN;
%mend;

%import(output=ss,path=C:\SAM\DQ\Data\SQL Data\CITY_PIN3.txt);
Ask a Question
Discussion stats
  • 2 replies
  • 147 views
  • 0 likes
  • 2 in conversation