Pick Your Variables Out

Chen Jie Cao, Xi Chen · 2011

How could one efficiently subset a large dataset with respect to the variables whose names are 10 digits long and have V in the last second position? Here we show a general method when the names of variables of interest share a particular pattern. It consists of two major steps: 1) PROC CONTENTS to store all the variable names as observations of one column in another dataset; 2) PROC SQL to select the names of variables of interest into a macro variable, which serves in a KEEP= option later. This method not only reduces typing or copy-pasting load, but also provides programmers great flexibility.

Read the paper · More papers on PaperTik