I have a rather large data set that has metadata related to each variable e.g. variable (column) name would be "qhyngage", and the label would read "age of youngest person in family".
I want to extract these labels along with the data into CSV/ xlsx format, so the end product would be the data set with the column names as the first row, then the labels as the second row etc.
I've already tried things from the "foreign" library in R such as dataset.labels <- as.data.frame(attr(dataset, "label")) but all this just returns NULL.
This is an example of what the characteristics of a column of data would look like in the R environment viewer:
qqhhtype : 'haven_labelled' num 24 13 4 1 ...
..-attr(*, "label")=chr "DV: Household type"
..-attr(*,"labels")= Named num -10 -9 -8 -7...
.. ..-attr(*,"names")=chr "[-10] Non-responding person" ...
End goal is to have a data set with all variables and observations but with an additional row that contains variable labels. (Currently just getting NULL for all labels)
Thank you so much for your help !