merge several data files into one file using sas macro

Reply
New Contributor
Posts: 3

merge several data files into one file using sas macro

Hi,

I create two data files using sas macro and am going to merge them into one data file.

When i use codes below, I've got a data set with variables in the last file (ID participation LastName).

My question is how i can capture different variables (ID participation FirstName LastName) from all the files using macro.

%macro missingness (xvar=);

data missing_&xvar ;

     set previous (keep=ID &xvar participation);

    if &xvar eq  " " ;

proc sort data=missing_&xvar;

     by ID;

data missing_all;

     merge missing_&xvar;

     by ID;

%mend missingness;

%missingness (xvar=FirstName);

%missingness (xvar=LastName);

run;

Regular Contributor
Posts: 227

Re: merge several data files into one file using sas macro

Posted in reply to peachblozzom

This is a list processing Q.

1. make the list of variables in the data set

2. fix your macro

3. call your macro for each character variable

1. make list: contents or sql

http://www.sascommunity.org/wiki/Making_Lists

%let MlnLibname = work;

%let MlnMemName = previous;

PROC SQL; create table Work.ListNames as

   select Name

   from  Dictionary.Columns

   where  Libname eq "%upcase(&MlnLibname.)"

   and  Memname eq "%upcase(&MlnMemname.)"

   and  MemType eq 'DATA'

   and Type eq 'char'

   ;

   quit;

2. rename parameter of your macro to match variable in list

%macro missingness (name=);

3.

http://www.sascommunity.org/wiki/Macro_CallMacr

%callmacr(data = &syslast

,macroname = missingness

)

Ron Fehd  list processing maven

Ask a Question
Discussion stats
  • 1 reply
  • 202 views
  • 0 likes
  • 2 in conversation