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.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.