The list command
list displays the values of variables. asdocx can export the output from list command to Excel, Word, HTML, or LaTeX. With the label option, both variable labels and values labels can be exported. Here is a working example to export its output to MS Excel.
sysuse nlsw88 asdocx list idcode age race married industry, label save(File.xlsx) replace
Table: Results
NLS id | age in current year | race | married | industry |
---|---|---|---|---|
1 | 37 | black | single | Transport/Comm/Utility |
2 | 37 | black | single | Manufacturing |
3 | 42 | black | single | Manufacturing |
4 | 43 | white | married | Professional Services |
6 | 42 | white | married | Manufacturing |
7 | 39 | white | married | Professional Services |
9 | 37 | white | single | Transport/Comm/Utility |
12 | 40 | white | married | Professional Services |
13 | 40 | white | married | Professional Services |
14 | 40 | white | married | Professional Services |
15 | 39 | white | married | Professional Services |
16 | 40 | white | married | Professional Services |
18 | 40 | white | married | Wholesale/Retail Trade |
19 | 40 | white | single | Professional Services |
20 | 39 | white | married | Professional Services |
22 | 41 | white | married | Professional Services |
23 | 42 | white | married | Professional Services |
24 | 41 | white | married | Professional Services |
25 | 42 | white | married | Professional Services |
36 | 37 | white | single | Business/Repair Svc |
39 | 44 | white | single | Professional Services |
44 | 41 | white | married | Public Administration |
45 | 35 | white | married | Transport/Comm/Utility |
46 | 44 | white | married | Professional Services |
47 | 35 | white | single | Transport/Comm/Utility |
48 | 35 | white | single | Finance/Ins/Real Estate |
50 | 36 | white | single | Professional Services |
51 | 38 | white | married | Professional Services |
54 | 40 | white | single | Professional Services |
57 | 42 | white | married | Wholesale/Retail Trade |
Notes: |
Both if and in qualifier are supported.
sysuse nlsw88 asdocx list idcode age race married industry in 1/20, label save(File.xlsx) replace
Other uses of list
The idea of using the list command as a tool of creating results table is to create a Stata dataset and export it. Several Stata commands can be used to create a new dataset of results from the existing one. The most commonly used command is the collapse command.
sysuse nlsw88 collapse (sum) wage , by(industry race) * Create a table from the collapsed data asdocx list
Table: Results
race | industry | wage |
---|---|---|
white | Ag/Forestry/Fisheries | 85.088 |
black | Ag/Forestry/Fisheries | 10.471 |
white | Mining | 61.398 |
white | Construction | 178.566 |
black | Construction | 29.206 |
other | Construction | 11.610 |
white | Manufacturing | 1825.607 |
black | Manufacturing | 903.049 |
other | Manufacturing | 24.423 |
white | Transport/Comm/Utility | 708.512 |
black | Transport/Comm/Utility | 308.709 |
other | Transport/Comm/Utility | 12.681 |
white | Wholesale/Retail Trade | 1692.344 |
black | Wholesale/Retail Trade | 347.580 |
white | Finance/Ins/Real Estate | 1670.564 |
black | Finance/Ins/Real Estate | 202.879 |
other | Finance/Ins/Real Estate | 16.446 |
white | Business/Repair Svc | 504.099 |
black | Business/Repair Svc | 129.296 |
other | Business/Repair Svc | 12.963 |
white | Personal Services | 248.610 |
black | Personal Services | 172.025 |
other | Personal Services | 6.271 |
white | Entertainment/Rec Svc | 106.585 |
black | Entertainment/Rec Svc | 7.729 |
white | Professional Services | 4997.315 |
black | Professional Services | 1393.120 |
other | Professional Services | 95.422 |
white | Public Administration | 1097.873 |
black | Public Administration | 469.742 |
other | Public Administration | 42.504 |
white | . | 55.307 |
black | . | 16.570 |
Notes: |
Two-ways table
After collapsing the data, we have two grouping variables, that are race and industry, and one numerical variables, i.e, wage. We can use the tabdisp command to create a two way table. The variable industry has 12 levels and race has three levels. Therefore, the table will look much better if we report industry in rows and race in columns. The values of the wage variables that occur at the intersection of the levels of industry and race will be reported in cells. The asdocx code for this is:
asdocx tabdisp industry race , c(wage) replace
Tabulation of industry race
race | |||
---|---|---|---|
industry | white | black | other |
Ag/Forestry/Fisheries | 85.088 | 10.471 | |
Mining | 61.398 | ||
Construction | 178.566 | 29.206 | 11.61 |
Manufacturing | 1825.607 | 903.049 | 24.423 |
Transport/Comm/Utility | 708.512 | 308.709 | 12.681 |
Wholesale/Retail Trade | 1692.344 | 347.58 | |
Finance/Ins/Real Estate | 1670.564 | 202.879 | 16.446 |
Business/Repair Svc | 504.099 | 129.296 | 12.963 |
Personal Services | 248.61 | 172.025 | 6.271 |
Entertainment/Rec Svc | 106.585 | 7.729 | |
Professional Services | 4997.315 | 1393.12 | 95.422 |
Public Administration | 1097.873 | 469.742 | 42.504 |
Notes: |
See also
- tabmany – Table of multiple coded answers
- mrtab – One- and two-way tables of multiple responses
- tabcount – tabulates frequencies for up to 7 variables
- missings – Various utilities for managing missing values
- tabulate, tab1, tab2
Order asdocx
Yearly license of asdocx is available at $9.99. Its life-time license is available at $49.99. With the asdocx membership, you get :
- Life-time license to use
- All future updates
- All premium templates / plugins.