Hey guys,
i wrote this small Macro . It compares two Datasets.
at the Point %comp(XXX,PatientOID); i will use for the call of the Dataset names the content of a variable, line by line, instead off.
There are many datasets to compare and i wrote the Dataset names with DIRLIST into a variable.
I hope you will understand me... THANKS A LOT
%macro comp(ds=,id=);
proc sort data=p3465_n.&ds out=&ds._new;
by &id;
run;
proc sort data = p3465_o.param_&ds out=&ds;
by &id;
run;
title "---- Compare proc contents of &ds -----";
proc compare base=&ds._new comp=&ds listall maxprint=(3200,3200);
id &id;
*where visitnum<50;
run;
title;
%mend;
%comp(XXX,PatientOID);
Do you mean you want to generate code something like this:
%comp(datasetname1,PatientOID)
%comp(datasetname2,PatientOID)
%comp(datasetname3,PatientOID)
...
UNTESTED CODE
proc sql noprint;
select distinct memname into :names separated by ' ' from dictionary.tables
where upcase(libname)='P3465_N';
quit;
%macro dothis;
%do i=1 %to %sysfunc(countw(&names));
%let thisname=%scan(&names,&i,%str( ));
%comp(&thisname,PatientOID)
%end;
%mend;
%dothis
And what is the question?
… ok:
this is the Macro Call.
%comp(XXX,PatientOID);
and in the Variable 'both' in the Field varname there stand the variable names.
i need a help to paste the variable names automatically to XXX.
Do you mean you want to generate code something like this:
%comp(datasetname1,PatientOID)
%comp(datasetname2,PatientOID)
%comp(datasetname3,PatientOID)
...
UNTESTED CODE
proc sql noprint;
select distinct memname into :names separated by ' ' from dictionary.tables
where upcase(libname)='P3465_N';
quit;
%macro dothis;
%do i=1 %to %sysfunc(countw(&names));
%let thisname=%scan(&names,&i,%str( ));
%comp(&thisname,PatientOID)
%end;
%mend;
%dothis
yes, … perhaps as a macro that takes eack new Observation of both and writes it as datasetname1,datasetname2 ...
Message #4 updated to include code.
Hello,
Do you want to use a reference dataset to generate macro calls ?
If so, here is a way to achieve this :
%macro comp(ds=, id=);
%put &=ds. &=id.;
%mend;
data meta;
input ds_name $ var_id $;
cards;
foo x
bar y
baz z
;
run;
data _NULL_;
set meta;
call execute(cats('%comp(ds=',ds_name,', id=',var_id,');'));
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.