Dear Statalist,
I'm trying to write an ado that searches all datasets within a given directory for variables whose names are either given or can be determined using regular expressions.
In the end I would simply like to pass a list to the ado, which can contain both concrete variable names as well as regular expressions or at least abbreviated variable names (such as *var, va*r or var*)
I would know how to do it relatively easily if I opened the data sets, but the problem is that I would like to avoid exactly that because I am dealing with very, very large data sets and otherwise the runtime would simply be too long.
So the challenge is to do it without fully opening any dataset.
I was thinking about looping over something like
but unfortunately in the resulting local varlist not the variables that match var* - as I would have expected - are stored, but rather all the variables in the data set. I'm very sure that there must be a fairly simple way to do this, but unfortunately I can't find it and would be very grateful for any help.
To give everyone an easy-to-follow example:
So my question is how to store the above result in a local.
Thank you for your help in advance
Benno
I'm trying to write an ado that searches all datasets within a given directory for variables whose names are either given or can be determined using regular expressions.
In the end I would simply like to pass a list to the ado, which can contain both concrete variable names as well as regular expressions or at least abbreviated variable names (such as *var, va*r or var*)
I would know how to do it relatively easily if I opened the data sets, but the problem is that I would like to avoid exactly that because I am dealing with very, very large data sets and otherwise the runtime would simply be too long.
So the challenge is to do it without fully opening any dataset.
I was thinking about looping over something like
Code:
describe var* using datset, varlist
To give everyone an easy-to-follow example:
Code:
// saving auto.dta filepaths to make the example executable for everyone quietly: sysuse auto local auto `r(fn)' clear describe t* using `"`auto'"', varlist // so the result shows the two variables trunk and turn display "`r(varlist)'" // but local varlist contains ALL variables in the dataset
Thank you for your help in advance
Benno
Comment