Hi,
I am trying to loop through datasets to process the date variables the same way (e.g., convert a daily date to "month" to check the frequencies over the course of the year using -tab-). Different datasets have different numbers of/names of date variables, but whether the dataset has 1 or 15 dates, I want it to do the same thing to all of them per dataset. For example
r
I am trying to loop through datasets to process the date variables the same way (e.g., convert a daily date to "month" to check the frequencies over the course of the year using -tab-). Different datasets have different numbers of/names of date variables, but whether the dataset has 1 or 15 dates, I want it to do the same thing to all of them per dataset. For example
- Dataset 1 might have just date_of_birth plus a dozen other non-date variables.
- Dataset 2 might have date_of_birth date_of_death admission_date and discharge_date plus another dozen non-date variables (and unfortunately not always with the same naming convention across all the date variables).
- But all the dates are formatted as %td.
- I'm imagining we'd have to loop through the full variable list in the open dataset, flag each variable that has format=%td and then store the list of found variables as a macro variable, after which I'd loop through each value in the macro variable to do whatever (e.g., recode date_of_birth to a variable stored as %tm and then -tab- the new monthly date variable and repeat for any additional date vars).
- I see in the -local- extended functions you can extract attributes for a given variable, but not extract variables based on a particular attribute (e.g., when format is %td). Perhaps this could be used to set a condition for the loop imagined above?
r
Comment