460 likes | 651 Views
Learning Objectives. By the end of this session, you should be able to:Create new variablesRecode variablesExport data from Epi InfoSave your output fileImport exported data into other statistical packages. What if I want to display the text of RACE instead of numeric codes?. Creating Varia
E N D
1. Epidemiologic Field Investigationsusing Epi Info:
2. Learning Objectives By the end of this session, you should be able to:
Create new variables
Recode variables
Export data from Epi Info
Save your output file
Import exported data into other statistical packages
3. What if I want to display the text of RACE instead of numeric codes?
4. Creating Variables The best way to achieve this is to create a new variable that contains the text of race.
Define a new variable
Recode numeric codes to text; store in new variable
Tabulate the new variable
5. DEFINE a new variable
6. Scope of a New Variable Standard: temporary; loses its value and definitions at next READ statement.
Standard variables can be assigned values from other variables.
Global: exists for duration of the analysis session.
Global variables are constant values; cannot be listed.
Permanent: has the same value regardless of the record; stored in system registry.
Used by application developers to pass values from one program to another.
7. RECODE a variable
8. RECODE Syntax RECODE race TO racetxt
1 = "White"
2 = "Black"
3 = "Hispanic"
END
12. Comment Legal Fields Comment Legal Fields are stored as numeric data.
FREQ of Comment Legal Fields gives numbers, not text.
13. Check the RECODE
14. How do I create a dummy variable for RACE?
15. DEFINE the variable
16. WHITE: Dummy (Dichotomous) Variable RACE WHITE
1 1
2
3
18. Collapsing Categories using RECODE DEFINE white
RECODE race TO white
1 = 1
2 - 3 = 0
END
19. Check the Creation of WHITE
20. How can I re-calculate age at interview?
21. Mathematical Calculations One can calculate age by using either of two methods:
ASSIGN and ROUND functions
ROUND(DAYS(birthdate,interview)/365.25)
YEARS function
YEARS(birthdate,interview)
22. Calculating Follow-up Time Similarly, one can calculate the follow-up time in months from follow_up and dateint.
Follow-up in months
MONTHS(interview, follow_up)
Follow-up in days
DAYS(interview, follow_up)
25. How do I get data out of Epi Info?
26. WRITE Data into Other Formats One can export data into other formats:
32. ODBC in Stata version 8 By setting up a Data Source Name, you can pull data directly from the mdb file into Stata.
Syntax:
.odbc load, exec(SELECT * FROM datatable1) dsn(Sample Data) clear
34. ODBC in R version 1.7.1 By setting up a Data Source Name and installing the RODBC package, you can pull data directly from the mdb file into R.
Syntax:
# CALL UP THE RODBC LIBRARY
library(RODBC)
## TELL R TO MAP IT TO NAMES OF THE DATABASE
chnldata <- odbcConnectAccess("c:\\Documents and Settings\\wayne_enanoria\\My Documents\\CIDP\\sampledatabase.mdb")
## LIST THE TABLES IN THE DATABASE
sqlTables(chnldata)
## FETCH THE TABLE YOU WANT
sampledata <- sqlFetch(channel=chnldata, sqtable="datatable1", rownames = TRUE)
## CLOSE THE CONNECTION
odbcClose(chnldata)
36. How do I relate two tables to one another?
37. Example Spreadsheet
39. RELATE Data Tables
42. Combined Table
43. Working With Output By default, output files are stored in the directory of the current project with a prefix followed by a number.
For example, Out16.html.
One can change how and where output files are stored by using the Storing Output Command.
44. RouteOut RouteOut command directs output to the named file until the process is terminated by the CloseOut command.
The named file is a HTM document where the output is stored.
If no directory is specified, the directory of the current project will be used.
45. Summary of Topics Import data from other formats
READ (Import) command
Create new variables
DEFINE and ASSIGN commands
Recode variables
DEFINE and RECODE commands
Export data from Epi Info
WRITE command
Import exported data into other statistical packages
EI -> text file -> other stat programs
EI -> other stat programs (ODBC)
Save your output file