-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVAR_EXIST.sas
27 lines (25 loc) · 855 Bytes
/
VAR_EXIST.sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*#####################################################################################*/
/* VAR_EXIST */
/*
%put %var_exist(sashelp.cars , model);
%put %var_exist(sashelp.cars , sandwich);
*/
%macro Var_Exist(ds,var);
%local rc dsid result;
%let dsid=%sysfunc(open(&ds));
%if %sysfunc(varnum(&dsid,&var)) > 0 %then %do;
%let result=1;
/*%put NOTE: Variable &var exists in &ds;*/
%end;
%else %do;
%let result=0;
/*%put NOTE: Variable &var does not exist in &ds;*/
%end;
%let rc=%sysfunc(close(&dsid));
&result
%mend ;
/*#####################################################################################*/
/* VARS_EXIST */
/*
%put %vars_exist(sashelp.cars , model model_name model_id);
*/