URGENT PROBLEM :HELP TO WRITE A MACRO IF I CALL THE LIBARAY NAME THEN ALL THE DATA SET SHOULD UNDERGO THE PROGRAM

Reply
Contributor
Posts: 34

URGENT PROBLEM :HELP TO WRITE A MACRO IF I CALL THE LIBARAY NAME THEN ALL THE DATA SET SHOULD UNDERGO THE PROGRAM

INPUT DATA SET :Smiley SurprisedNE::

STUDYIDDOMAINUSUBJIDSUBJIDSITEIDAESEQAESPIDAETERMAEPTNAEBODSYSAESERAEACNAERELAEOUT
CYT1532AE01532 0127 0005   12700050127160101COLD SENSITIVITY ORALSENSORY DISTURBANCECENTRAL & PERIPHERAL NERVOUS SYSTEM DISORDERSNNYONGOING (PERSISTENT)
CYT1532AE01532 0127 0005   12700050127160101COUGHCOUGHINGRESPIRATORY SYSTEM DISORDERSNNNRECOVERED WITH SEQUELAE
CYT1532AE01532 0127 0005   12700050127160101DIARRHEADIARRHOEAGASTRO-INTESTINAL SYSTEM DISORDERSNNYONGOING (PERSISTENT)

ANOTHER DATASET TWO::::

data Metadata;

input element $ domain $ action $;

datalines;

SUBJID DM NONE

USUBJID DM NONE

DOMAIN DM GROUP

SITEID DM DROP

STUDYID DM DROP

RFSTDTC DM NONE

SUBJID AE NONE

USUBJID AE DROP

DOMAIN AE NONE

SITEID AE DROP

STUDYID AE AGEINT

AETERM AE GROUP

AELIFE AE DROP

AEDECOD AE NONE

AEHOSPP AE DROP

;

run;

MY CODE ::

proc contents data=WORKS.Aedata out=_ae(keep=name) varnum;

run;

data WORKS.Metadata  Metadata;

set WORKS.Metadata;

element =upcase(element);

run;

proc sql;

create table ae_meta as

select *

from _ae , Metadata

where _ae.name=Metadata.element and  action ne "DROP";

quit;

proc sql noprint;

select distinct name into :keepvar separated by ' ' from ae_meta;

quit;

data final ;

     set works.Aedata;

     keep &keepvar;

PROC Star
Posts: 1,290

Re: URGENT PROBLEM :HELP TO WRITE A MACRO IF I CALL THE LIBARAY NAME THEN ALL THE DATA SET SHOULD UNDERGO THE PROGRAM

Hi,

Even with urgent problems (especially with urgent problem), I would avoid subject line in all caps (shouting), and would take more time to describe your question.

It's not clear to me if you are having a problem with a macro you are trying to write, or if you are asking someone to write a macro for you.

There probably are people here who might write a macro for you, but again, a better description of what you are hoping they might write would help them help you.

Kind Regards,

--Q.

Contributor
Posts: 34

Re: URGENT PROBLEM :HELP TO WRITE A MACRO IF I CALL THE LIBARAY NAME THEN ALL THE DATA SET SHOULD UNDERGO THE PROGRAM

Sorry !

I am trying to write a macroSmiley Tongueerform repeated MACRO OVER ALL Data Sets in a SAS Library.

I have 2 data set  above. and i have wrote for single data set,But going further i don't want to give the data set name .only the macro should work on SAS LIBRARY.

Regular Contributor
Posts: 226

Re: URGENT PROBLEM :HELP TO WRITE A MACRO IF I CALL THE LIBARAY NAME THEN ALL THE DATA SET SHOULD UNDERGO THE PROGRAM

take your pick sql or contents

Proc SQL as Proc Contents - sasCommunity

proc contents data = sashelp._all_

                     noprint

              out  = list_variables;

proc freq     data = &syslast;

              tables memname /noprint

              out  = list_data_sets;

proc print    data = &syslast;

Once you have a list of data sets then you can pass memname into your macro call

with macro CallMacro

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

Ron Fehd macro maven

Regular Contributor
Posts: 226

Re: URGENT PROBLEM :HELP TO WRITE A MACRO IF I CALL THE LIBARAY NAME THEN ALL THE DATA SET SHOULD UNDERGO THE PROGRAM

automagic

%let libname = sashelp;

proc contents data = &libname.._all_

                     noprint

              out  = list_variables;

proc freq     data = &syslast;

              tables memname *nobs /noprint

              out  = list_data_sets;

proc print    data = &syslast;

*include sasautos(callmacr);

%macro showparms

       (libname=libref

       ,memname=data

       ,nobs=0

       ,count=0

       ,percent=0);

%put _local_;

%mend;

%showparms()

%callmacr(data=&syslast

         ,macro_name  = showparms

         ,macro_parms = %nrstr(libname=&libname)

         ,hex16       = 0

         )

Ron Fehd  automation maven

Super User
Posts: 19,052

Re: URGENT PROBLEM :HELP TO WRITE A MACRO IF I CALL THE LIBARAY NAME THEN ALL THE DATA SET SHOULD UNDERGO THE PROGRAM

Have you solved your problem?

Ask a Question
Discussion stats
  • 5 replies
  • 274 views
  • 1 like
  • 4 in conversation