Specialized on Data processing, Data management Implementation plan, Data Collection tools - electronic and paper base, Data cleaning specifications, Data extraction, Data transformation, Data load, Analytical Datasets, and Data analysis. BJ Data Tech Solutions teaches on design and developing Electronic Data Collection Tools using CSPro, and STATA commands for data manipulation. Setting up Data Management systems using modern data technologies such as Relational Databases, C#, PHP and Android.
Tuesday, December 8, 2020
Attempting to export two-way cross-tabulations using tab2xl - having issues in exporting it in the format I need it to be.*
I am pasting my do-file here using a common data set.
***data for question
webuse auto
codebook foreign
tab mpg
sum mpg
**generating mpg_categories for example
generate mpg_categories=.
replace mpg_categories=1 if mpg>22
replace mpg_categories=2 if mpg<=22
label define lab_mpg_cat 1 "Mileage>22" 2 "Mileage<=22"
label values mpg_categories lab_mpg_cat
codebook mpg_categories
******General problem
/*
I have Stata 16.1, I am trying to output cross-tabs into excel sheets in a format which is convenient for direct upload on Tableau for visualisation, using the auto dataset as an example because I cannot use organisational data*/
***I am trying to produce an excel sheet for the tabulate command
tab mpg_categories
***I am using the following to output data to an excel file for one way tables and this is working fine (output 1)
tab2xl mpg_categories using problem_1, row(1) col(1) sheet("sheet 1")
******Specific problem
/*I am also trying to export this exact output (output 2) to an excel file using tab2xl.
I have been trying for sometime, but I am unable to export the output. I am trying to do this for a lot of variables, so the idea is to loop through the variables and export output 1 and output 2 to excel sheets and then upload them directly to tableau.*/
**output 2
tab foreign mpg_categories, column nofreq
**this is as far as I got
tab2xl foreign mpg_categories using problem_1, row(1) col(1) sheet("sheet 2")
**as you can see, I am not getting the percentages, if anyone has any ideas please let me know!
No comments:
Post a Comment