%let tableletter = %scan(a b c d e f g h i j k l m n o p q r s t u v w x y z, &div.)%scan(a b c d e f g h i j k l m n o p q r s t u v w x y z, &secondplace);
****************************************************************************************************
****************************************************************************************************
* PROGRAM: utility_macros.sas
* Created (mm/dd/yyyy): 12/20/2020
*--------------------------------------------------------------------------------------------------
* PURPOSE: This program includes the following macros:
* - %isdata() macro determines whether a dataset is empty or not
* - %create_comma_charlist() macro converts space delimited list to comma delimited list with quotes
* - %alphabetizevarutil() macro alphabetizes variables in a data step
* - %tableletter() macro increments a letter suffix
* - %varexist() macro checks for the existence of a variable
* - %convert_categories() macro converts categories to mathematical expression
* - %output_datasets() macro output SAS datasets
* - %nonrep() macro removes repeated words in macro variable
* - %varlength macro gets a variable length and type
*--------------------------------------------------------------------------------------------------
* Sentinel Coordinating Center
* info@sentinelsystem.org
***************************************************************************************************;
*Macro to determine whether a dataset is empty or not;
%if %sysfunc(exist(&dataset.))=1 and %LENGTH(&dataset.) ne 0 %then %do;
call symputx("NOBS",attrn(dsid,"NLOBS"));
*Macro for converting macro variable with space deliminated list to comma deliminated list with quotation around each word;
%macro create_comma_charlist(inlist=, outlist=);
%let countvars = %sysfunc(Countw(%quote(&inlist.), ' '));
%do c = 1 %to &countvars.;
%let word = %scan(%quote(&inlist),&c., ' ');
%let &outlist. = "&word.";
%let &outlist. = &&&outlist. , "&word.";