Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extended Codebook Data #9

Closed
paynejason opened this issue Aug 23, 2022 · 7 comments
Closed

Extended Codebook Data #9

paynejason opened this issue Aug 23, 2022 · 7 comments

Comments

@paynejason
Copy link

Hello,

This tool is very helpful, thank you for making it. I am currently working on a project with NHANES that also assesses the Codebook/variable data, so your nhanesTableVars functionality is life-saving.

On that front, is there any way to extend that functionality to include the expected values and their keys? For example, variable AUQ020D has label Earache Last 24 Hours, Left? , has a description Have you had an earache in left ear in the last 24 hours? and the set of expected values Yes No Don't know or Missing. The raw data does not exist in any form I have been able to find or download and it would be invaluable.

@cjendres1
Copy link
Owner

Hi Jason,
nhanesTranslate will retrieve the expected values for any variable
E.g., you can get all valid values for AUQ020D with
nhanesTranslate('AUX_D', "AUQ020D")

nhanesTableVars with namesonly=TRUE will pass back the variable names. You can then loop through the variables and call nhanesTranslate for each desired variable.
Is that what you wanted?

Thanks for using nhanesA!
Chris

@cjendres1
Copy link
Owner

Someone else also commented on the codebook label which is currently not returned by nhanesTranslate. Would help if you can write out a simple example of your desired output.

@paynejason
Copy link
Author

Hi Chris,
Thank you for the response, the data was just what I was looking for!

In regards to the other person, we are actually working on the same project, so I'm not sure how much light I can shed on the situation. However, we are looking for the SAS Label and Target information as seen here:
image

Not sure if this helps, but thank you again!

@cjendres1
Copy link
Owner

That clears things up actually. If you want that full description returned including the text fields and the additional columns (Count, Cumulative, Skip) then the behavior is different enough from nhanesTranslate that I will create a new function: nhanesCodebook. Should have it ready in a couple days.

@cjendres1
Copy link
Owner

After further consideration ... this will be easier than I thought. Adding details = TRUE already gives you the last columns.
try
nhanesTranslate('AUX_D', "AUQ020D", details=TRUE)

Just need to add the text fields

@cjendres1
Copy link
Owner

nhanesCodebook.txt
Please rename the attached file to nhanesCodebook.R for some reason it doesn't allow attaching '.R' files
In your R session
1: source('nhanesCodebook.R')
2: nhanesCodebook('AUX_D', 'AUQ020D')

Let me know if the result of the last command is what you're looking for. It's a list since there's a mixture of data types.
Please test it out as much you can and let me know if there's any unexpected behavior.
Thanks!

@paynejason
Copy link
Author

This is perfect, thank you so much for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants