Is there a function in the haven package that would allow to directly extract the names of a SAS dataset? Is there one to read the labels?
I could not find any hints from the read_sas function documentation. Right now, the best (but a bit inefficient) I can do is to read the file with read_sas and get the variables names with the names function and the labels with some mix of sapply and attr...
I expect you are asking for a direct approach because for your use case it might be considered wasteful to read entire dataset, thereby make a dataframe, and from that get column names .
The good news is that read_sas has an n_max Param to limit number of records. You could test if it works for n_max 0 as well as for n_max 1
@pomchip: I'm not sure your issue is similar, but a recent encounter with labeled data led me to use haven's as_factor() command, which lets you explicitly get your hands on the labels.