{smcl} {* 24Oct2011}{...} {* Program written by Alberto A. Gaggero alberto.gaggero@unipv.it} {hi:help csvconvert} {hline} {title:Title} {p2colset 5 20 22 2}{...} {p 8 16 2} {cmd:csvconvert} {hline 1} module for gathering multiple comma-separated values (.csv) files into one single Stata (.dta) dataset.{p_end} {p2colreset}{...} {title:Syntax} {p 8 16 2} {opt csvconvert} {it:input_directory} [{cmd:,} {it:options}] {p 8 16 2} Note: all .csv files must be placed in the same directory; {it:input_directory} is the directory where the .csv files must be stored. {synoptset 31 tabbed}{...} {synopthdr} {synoptline} {synopt :{opt output_file(file_name)}}{it:file_name} is the name of the .dta file; default is "output.dta".{p_end} {synopt :{opt output_dir(output_directory)}}{it:output_directory} is the directory where the output file is saved; default is {it:input_directory}.{p_end} {synopt :{opt input_file(.csv file list)}}names of the .csv files placed in {it:input_directory} to be converted; you must specify the extension .csv for each file name included in the list (see examples below). If this option is not specified, csvconvert takes into the process all the .csv files stored in {it:input_directory}.{p_end} {synoptline} {pstd}Double quotes must NOT be used to enclose {it:input_directory} nor {it:output_directory}, even if the directory path contains spaces. {title:Description} {p 8 8 2} {cmd:csvconvert} appends a set of .csv files into one single file, which is saved in the .dta format, immediately readable into Stata. {break} This command suits the case in which the researcher holds multiple data files differing by - for example - a period variable, typically year. {p 8 8 2} By default, {cmd:csvconvert} creates a new variable, _csvfile, containing the name of the .csv file from which the observation originates. {break} At the end of the process {cmd:csvconvert} displays a message with the number of the original .csv files that have been included in the .dta file. {break} (this information can become useful to double check that all the .csv files have been converted into the .dta file). {title:Examples} {pstd}Donwload trail sample from {browse "https://sites.google.com/site/albertogaggero/csvconvert":my webpage} and store the files in a directory you created - for example C:\Data\worldbank. {pstd}Check that all the .csv files are in the same directory - in this example C:\Data\worldbank {p_end} {phang2}{cmd:. dir C:\Data\worldbank\*.csv} {pstd}The following command creates the file output.dta and saves it in the directory C:\Data\worldbank {p_end} {phang2}{cmd:. csvconvert C:\Data\worldbank} {pstd}The following command creates the file wb_data.dta and saves it in the directory C:\Data\wb dataset{p_end} {phang2}{cmd:. csvconvert C:\Data\worldbank, output_file(wb_data.dta) output_dir(C:\Data\wb dataset)} {pstd}The following command includes in output.dta only the selected .csv files wb2008.csv and wb2009.csv{p_end} {phang2}{cmd:. csvconvert C:\Data\worldbank, input_file(wb2008.csv wb2009.csv)} {pstd} Similar to the commands above: the files wb2008.csv and wb2009.csv are stored into wb_data.dta, which is saved in C:\Data\wb dataset{p_end} {phang2}{cmd:. csvconvert C:\Data\worldbank, input_file(wb2008.csv wb2009.csv) output_file(wb_data.dta) output_dir(C:\Data\wb dataset)} {title:Author} Alberto A. Gaggero, University of Pavia, Italy alberto.gaggero@unipv.it {title:Also see} {psee} Manual: {manlink D append}, {manlink D insheet} {psee} {space 2}Help: {manhelp append D: append}, {manhelp insheet D: insheet} {p_end}