{smcl} {* 29Jun2008}{...} {cmd:help wfdataset} {hline} {title:Title} {p2colset 5 12 24 2}{...} {p2col:{hi:Steps when creating and saving a dataset}}{p_end} {title:List of steps} {p2colset 5 9 9 2}{...} {p2col:1.}Selecting observations.{p_end} {p2col:2.}Selecting variables.{p_end} {p2col:3.}Creating variables.{p_end} {p2col:4.}Adding variable labels.{p_end} {p2col:5.}Adding notes to variables.{p_end} {p2col:6.}Adding value labels.{p_end} {p2col:7.}Rearranging variables.{p_end} {p2col:8.}Internal documentation for a dataset.{p_end} {p2col:9.}Adding a datasignature.{p_end} {p2col:10.}Saving the dataset.{p_end} {title:1. Selecting observations} {it:Drop observations based on comparison} {cmd:keep if} {it:exp} {cmd:drop if} {it:exp} For example: {cmd: drop if female==1} {it:Drop observations based on observation number} {cmd:keep in} {it:numeric list} {cmd:drop if} {it:numeric list} For example: {cmd: drop in 1/22} {title:2. Selecting variables} {cmd:keep } {it:variable list} {cmd:drop } {it:variable list} For example: {cmd: drop female year tempvar} {cmd: keep var1-var090} {title:3. Create new variables} {cmd:generate }{it:newvar} {cmd:=} {it:exp} [{cmd:if}] [{cmd:in}] {cmd:clonevar }{it:newvar} {cmd:=} {it:sourcevar} [{cmd:if}] [{cmd:in}] {cmd:replace }{it:newvar} {cmd:=} {it:exp} [{cmd:if}] [{cmd:in}] {it:Principles for creating new variables} {p2col:1.}If a variable is new, give it a new name.{p_end} {p2col:2.}Verify that new variables are constructed correctly.{p_end} {p2col:3.}Document new variables with notes and labels.{p_end} {p2col:4.}Keep the source variables used to create new variables.{p_end} {title:4. Adding variable labels} {cmd:label variable} {it:varname} "{it:label}" For example: {cmd:label var artsqrt "Square root of # of articles"} {it:Commands for listing variable labels and other information} {cmd:codebook} [{it:varlist}] [{cmd:if}] [{cmd:in}] {cmd:, compact} {cmd:describe} [{it:varlist}] [{cmd:if}] [{cmd:in}] {cmd:, simple fullnames numbers} {cmd:nmlab} {it:varlist} {cmd:tab1} {it:varlist} {title:5. Adding notes to variables} {cmd:note} {it:variable name} {cmd:"}{it:variable label}{cmd:"} For example: {cmd:local tag "pub# truncated at 20 \ wf5-varnotes.do jsl 2008-04-09."} {cmd:note pub1trunc: `tag'} {title:6. Adding value labels to variables} {it:Step 1: Defining labels} (ideally, 10 characters or shorter) {cmd:label define Lyesno 1 1_yes 0 0_no} {it:Step 2: Assigning labels} {cmd:label value wc Lyesno} {title:7. Rearranging variables.} {cmd:aorder} [{it:varlist}] {cmd:order} {it:varlist} {cmd:move} {it:variable-to-move target-variable} For example: {cmd:aorder} {cmd:order id} {title:8. Internal documentation for a dataset.} {cmd:label data "Workflow data from Russian ISSP 2002 \ 2008-04-02"} {cmd:note: wf-isspru02.dta \ workflow ch 6 \ wf6-save.do jsl 2008-04-05} {title:9. Adding a datasignature.} {cmd:datasignature set} To confirm: {cmd:use wf-datasig02, clear} {cmd:datasignature confirm} To change the signature after modifications to the dataset: {cmd:datasignature set, reset} {title:11. Saving the dataset} {cmd:quietly compress} {cmd:saveold mydata, replace} {title:Also see} {helpb wf} INCLUDE help wf_footer