thomas-rasmussen / sas_macros

SAS macros
Creative Commons Zero v1.0 Universal
5 stars 4 forks source link

smooth_periods: option varinitchk = error exposes "bug" #59

Closed thomas-rasmussen closed 1 year ago

thomas-rasmussen commented 1 year ago

If the macro is used on variables with formats, eg example 2, with option varinitchk = error, the macro terminates with an error about and unitialized variable (YYMMDD in case of example 2). The problem is https://github.com/thomas-rasmussen/sas_macros/blob/2aec20ca55b627477cb4434fe324d0cf9d80f24b/smooth_periods.sas#L388-L389 &start_format and &end_format are lacking a "." suffix, so the macro thinks a (non existing) variable is specified. The problem could be fixed by appending a "." to &start_format and &end_format, but this is actually also unnecessary, because __tmp_start and __tmp_end is not outputted to \<out>, but instead the original \<start> and \<end> variables are overwritten https://github.com/thomas-rasmussen/sas_macros/blob/2aec20ca55b627477cb4434fe324d0cf9d80f24b/smooth_periods.sas#L438-L439 So we can simply remove l.338-l.389 to remove the issue. In any case, the error in the code does not actually create a bug because of l.438-439, so in the meantime just don't use macro with option varinitchk = error...