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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.