Hi
The catx is giving me error.If the variable is not in the dataset I need to concatinate all the missing variables and display a message "Missing required vaiables : show the names here).
I need to do it in a macro. If I can use scan and catx together then great. If there is away to reduce the number of lines in the code would be great.
Any help is kindly appreciated!
%Macro testm(inds=, outds=);
%let lst = %str(NAME,AGE,SEX,RACE,COUNTRY);
%let dsid = %sysfunc(open(&inds));
%let chk1 = %sysfunc(varnum(&dsid, NAME));
%let chk2 = %sysfunc(varnum(&dsid,AGE));
%let chk3 = %sysfunc(varnum(&dsid,SEX));
%let chk4 = %sysfunc(varnum(&dsid,RACE));
%let chk5 = %sysfunc(varnum(&dsid, COUNTRY));
%let rc = %sysfunc(close(&dsid));
%let lsto= ;
%do i = 1 %to 5;
%local var&i. ;
%If &&chk&i = 0 %then
%let var&i. =%scan(&lst., &i., %str(,));
%end;
%end;
%mend testm;
%testm(inds=C_TEST, outds=tt);
In macro language you don't need CAT functions. Also don't use commas for variable list delimiters, it makes "everything" harder and SAS doesn't do it that way.
Here is what I think you want but in my opinion this is too much trouble. I like to use PROC TRANSPOSE to check for this. See second example.
In macro language you don't need CAT functions. Also don't use commas for variable list delimiters, it makes "everything" harder and SAS doesn't do it that way.
Here is what I think you want but in my opinion this is too much trouble. I like to use PROC TRANSPOSE to check for this. See second example.
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.