Learn how to use the gtools package command defmacro to develop a macro to run repeated frequencies on categorical variables.
- [Narrator] To save us time and effort…writing code for all of our frequencies,…in this movie we will cover making a macro to do this work.…Welcome to chapter five, section four.…In the last section, we made some code…that output overall frequencies of asthma…and of alcohol consumption into CSVs.…We opened them up and copy/pasted them…into categorical table one.…But then, we realized we had to do that…a zillion more times.…So this movie will explain how to make a macro.…
We will use the gtools library so we can use…the defmacro command.…I'll show you how to set up the arguments…in the macro, guided by the code we wrote…in the last section which we know works.…And I'll show you how to then load the macro…and call it up a bunch of times.…To do the macro, you have to load the package gtools,…and then we'll call up gtools in our library.…Then after that, we will use defmacro…to define the macro.…So let's look at our code.…
What changes each time?…Well, the input variable changes each time.…So let's have a variable called InputVar.…
This detailed, practical course is designed to help those in the field of public health, medicine, and data science to edit, analyze, and interpret data. Learn how to code new variables, use the forward-stepwise modeling process, and document your decisions. Find out how to visualize results by generating charts and graphics, and how to add tables and figures to your documentation. This course helps equip you to independently design, develop, and execute a full BRFSS analysis, and even publish your results in scientific publications or journals.
- Reviewing survey data and documentation
- Conducting a BRFSS analysis
- Understanding naming conventions
- Editing variables
- Reviewing distributions
- Generating an analytic dataset
- Developing descriptive statistics to answer prespecified hypotheses
- Preparing publication-worthy tables and plots
Skill Level Advanced
1. What Is the BRFSS?
2. Designing Your Metadata
3. Reading in Data and Applying Exclusions
4. Preparing for Descriptive Analysis
5. Conducting Descriptive Analysis
Making a frequency macro4m 8s
6. Descriptive Analysis: Weights and Tests
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.