User:Timeshifter/Sandbox141

Rates
Return to top.

There is an easy way to convert the first table below to the format of the partial table below it. The lower table with the years in the top row is an older version that needed to be updated with later years, and with the corrected data for older years. See the updated version of the table here:
 * United States drug overdose death rates and totals over time.

Rates are per 100,000 population.

Pivot table (from LibreOffice Calc) copied into Visual Editor
Conversion can be done quickly in freeware LibreOffice Calc. Use "Pivot Table" command in Calc. Here is a Google search: One page it pulls up is this one:
 * https://www.google.com/search?q=libreoffice+calc+pivot
 * https://elearn.ellak.gr/mod/page/view.php?id=3015

Copy the above table to Calc. Or import the CSV file (or other file format) for the table. Select a data cell. Then click on the "Pivot Table" command from the Insert menu. Click OK in the popup box. In the next dialog box drag "Year" to the "Column Fields" box, and drag "State" to the "Row Fields" box. Drag "Rate" to the "Data Fields" box. Click OK. The table will convert to the new format with the years as column headers.

Copy the new table directly from the LibreOffice Calc page into visual editor. Then delete the summation column and row.

See: List of U.S. state and territory abbreviations. The 2-letter state abbreviations in the Calc table copied below are not in the same alphabetical order as the full state names. In the table that follows it below use Visual Editor to move rows where they need to be. Then copy the data columns from the table below into the table in the Wikipedia article.