├── .Rbuildignore ├── .github ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md └── ISSUE_TEMPLATE.md ├── .gitignore ├── .travis.yml ├── DESCRIPTION ├── LICENSE ├── LICENSE.md ├── NAMESPACE ├── NEWS.md ├── R ├── helper.R ├── make_sps_setup.R ├── parse_setup.R ├── read_ascii_setup.R ├── read_ascii_setup_addin.R ├── sas.R ├── spss.R ├── utils-data-table.R └── utils.R ├── README.Rmd ├── README.md ├── appveyor.yml ├── asciiReader.Rproj ├── codecov.yml ├── cran-comments.md ├── docs ├── 404.html ├── CODE_OF_CONDUCT.html ├── CONTRIBUTING.html ├── ISSUE_TEMPLATE.html ├── LICENSE-text.html ├── LICENSE.html ├── articles │ ├── Introduction_to_asciiReader.html │ ├── Introduction_to_asciiSetupReader.html │ ├── Introduction_to_asciiSetupReader_files │ │ ├── accessible-code-block-0.0.1 │ │ │ └── empty-anchor.js │ │ ├── elevate-section-attrs-2.0 │ │ │ └── elevate-section-attrs.js │ │ ├── header-attrs-2.3.2 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.4 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.6 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.7 │ │ │ └── header-attrs.js │ │ └── jquery-1.11.3 │ │ │ └── jquery.min.js │ ├── index.html │ ├── making-an-sps-file.html │ ├── making-an-sps-file_files │ │ ├── accessible-code-block-0.0.1 │ │ │ └── empty-anchor.js │ │ ├── elevate-section-attrs-2.0 │ │ │ └── elevate-section-attrs.js │ │ ├── header-attrs-2.3.2 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.4 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.6 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.7 │ │ │ └── header-attrs.js │ │ └── jquery-1.11.3 │ │ │ └── jquery.min.js │ ├── making_a_sps_setup_file.html │ ├── making_a_sps_setup_file_files │ │ └── figure-html │ │ │ ├── unnamed-chunk-1-1.png │ │ │ └── unnamed-chunk-1-2.png │ ├── making_an_sps_setup_file.html │ ├── making_an_sps_setup_file_files │ │ └── figure-html │ │ │ ├── unnamed-chunk-1-1.png │ │ │ └── unnamed-chunk-1-2.png │ ├── parsing-an-sps-or-sas-file.html │ ├── parsing-an-sps-or-sas-file_files │ │ ├── accessible-code-block-0.0.1 │ │ │ └── empty-anchor.js │ │ ├── elevate-section-attrs-2.0 │ │ │ └── elevate-section-attrs.js │ │ ├── header-attrs-2.3.2 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.4 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.6 │ │ │ └── header-attrs.js │ │ ├── header-attrs-2.7 │ │ │ └── header-attrs.js │ │ └── jquery-1.11.3 │ │ │ └── jquery.min.js │ ├── parsing_a_sps_setup_file.html │ └── parsing_a_sps_setup_file_files │ │ └── figure-html │ │ ├── unnamed-chunk-1-1.png │ │ └── unnamed-chunk-1-2.png ├── authors.html ├── bootstrap-toc.css ├── bootstrap-toc.js ├── docsearch.css ├── docsearch.js ├── index.html ├── link.svg ├── news │ └── index.html ├── pkgdown.css ├── pkgdown.js ├── pkgdown.yml └── reference │ ├── Rplot001.png │ ├── figures │ └── asciiSetupReader_badge.png │ ├── index.html │ ├── make_sps_setup.html │ ├── parse_setup.html │ ├── parse_spss.html │ ├── read_ascii_setup.html │ ├── read_ascii_setup_addin.html │ ├── sas_ascii_reader.html │ └── spss_ascii_reader.html ├── inst ├── extdata │ ├── example_data.zip │ ├── example_setup.sas │ └── example_setup.sps ├── rstudio │ └── addins.dcf └── testdata │ ├── 1980_leoka_sas.zip │ ├── 1980_leoka_sps.zip │ ├── 1981_SHR_sas.zip │ ├── 1981_SHR_sps.zip │ ├── 1985_UCR_offenses_known_sas.zip │ ├── 1985_UCR_offenses_known_sps.zip │ ├── 1986_UCR_offenses_known_sas.zip │ ├── 1986_UCR_offenses_known_sps.zip │ ├── 1987_SHR_sas.zip │ ├── 1987_SHR_sps.zip │ ├── 1988_SHR_sas.zip │ ├── 1988_SHR_sps.zip │ ├── 2000_UCR_offenses_known_sas.zip │ ├── 2000_UCR_offenses_known_sps.zip │ ├── 2006_UCR_offenses_known_sas.zip │ ├── 2006_UCR_offenses_known_sps.zip │ ├── 2017_sadc_sas_input_program.sas │ ├── 2017_sadc_spss_input_program.sps │ ├── CA_SEDD_2005_AHAL.sps │ ├── UN_crime.sas │ ├── UN_crime.sps │ ├── WB2016.sas │ ├── WB2016.sps │ ├── acs_sas.zip │ ├── acs_sps.zip │ ├── british_crime_teen_sas.zip │ ├── british_crime_teen_sps.zip │ ├── ca_vital.sas │ ├── ca_vital.sps │ ├── ca_vital.zip │ ├── cambridge_sas.zip │ ├── cambridge_sps.zip │ ├── census_of_police.sas │ ├── census_of_police.sps │ ├── china_1995.sas │ ├── china_1995.sps │ ├── china_1998.sas │ ├── china_1998.sps │ ├── china_2002.sas │ ├── china_2002.sps │ ├── corrections_prison_admissions_1991_2016.sas │ ├── corrections_prison_admissions_1991_2016.sps │ ├── county_arrest.sas │ ├── county_arrest.sps │ ├── cps_1973_sas.zip │ ├── cps_1973_sps.zip │ ├── cps_2004_sas.zip │ ├── cps_2004_sps.zip │ ├── crosswalk.sas │ ├── crosswalk.sps │ ├── crosswalk2012.sps │ ├── detroit_sas.zip │ ├── detroit_sps.zip │ ├── drug_abuse_sas.zip │ ├── drug_abuse_sps.zip │ ├── dutch_election_study_sps.zip │ ├── education_1985.sas │ ├── education_1995.sas │ ├── escolar.SPS │ ├── escolar_2006_sps.zip │ ├── guam_sas.zip │ ├── guam_sps.zip │ ├── health_and_nutrition.sas │ ├── health_and_nutrition.sps │ ├── india_human_development_sas.zip │ ├── india_human_development_sps.zip │ ├── indonesia.sas │ ├── indonesia.sps │ ├── jail_survey_1987.sas │ ├── jail_survey_1987.sps │ ├── jail_survey_1987.zip │ ├── jail_survey_2010.sas │ ├── jail_survey_2010.sps │ ├── missing_value_no_s_setup_sps.zip │ ├── monitoring_the_future_1979_sps.zip │ ├── monitoring_the_future_1989_sps.zip │ ├── monitoring_the_future_1990_sps.zip │ ├── monitoring_the_future_1991_sps.zip │ ├── monitoring_the_future_1992_sps.zip │ ├── monitoring_the_future_1993_sps.zip │ ├── monitoring_the_future_1999_sps.zip │ ├── monitoring_the_future_2002_sps.zip │ ├── monitoring_the_future_2003_sps.zip │ ├── monitoring_the_future_2004_sps.zip │ ├── monitoring_the_future_2012_sps.zip │ ├── mtf_2019_8_10_sps.zip │ ├── ncvs_1979_sas.zip │ ├── ncvs_1979_sps.zip │ ├── nibrs_2000_batch_header1.zip │ ├── nibrs_2000_batch_header1_sas.zip │ ├── nibrs_2000_batch_header1_sps.zip │ ├── parole_survey.sas │ ├── parole_survey.sps │ ├── parole_survey.txt │ ├── prisoners_sas.zip │ ├── prisoners_sps.zip │ ├── psid_all_sas.zip │ ├── psid_core_sas.zip │ ├── psid_core_sps.zip │ ├── psid_main_sas.zip │ ├── psid_main_sps.zip │ ├── psid_supplement.sas │ ├── psid_supplement.sps │ ├── psid_toy.sas │ ├── sacramento.txt │ ├── sacramento_sas.zip │ ├── sacramento_sps.zip │ ├── sex_offender_notification.sas │ ├── sex_offender_notification.sps │ ├── sex_offender_notification.txt │ ├── starting_number_bigger_than_ending_number.sps │ ├── step_in.sas │ ├── step_in.sps │ ├── study_of_adolescent_health.sps │ ├── ucr1960.zip │ ├── ucr1960_sas.zip │ ├── ucr1960_sps.zip │ ├── ucr_property_stolen_1998_sas.zip │ ├── ucr_property_stolen_1998_sps.zip │ ├── weimar.txt │ ├── weimar_sas.zip │ ├── weimar_sps.zip │ ├── worry_sas.zip │ └── worry_sps.zip ├── man ├── figures │ └── asciiSetupReader_badge.png ├── make_sps_setup.Rd ├── parse_setup.Rd ├── read_ascii_setup.Rd ├── read_ascii_setup_addin.Rd ├── sas_ascii_reader.Rd └── spss_ascii_reader.Rd ├── tests ├── testthat.R └── testthat │ ├── setup.R │ ├── test-all-value-labels-assigned.R │ ├── test-column-names.R │ ├── test-column-type.R │ ├── test-dimensions-missing.R │ ├── test-error.R │ ├── test-missing-values.R │ ├── test-parse-value-labels-sas.R │ ├── test-parse-value-labels-sps.R │ ├── test-parser-missing-sas.R │ ├── test-parser-missing-sps.R │ ├── test-parser-sas.R │ ├── test-parser-sps.R │ ├── test-psid-test.R │ ├── test-silent.R │ └── test-value-labels.R └── vignettes ├── .gitignore ├── Introduction_to_asciiSetupReader.R ├── Introduction_to_asciiSetupReader.Rmd ├── Introduction_to_asciiSetupReader.html ├── making-an-sps-file.Rmd ├── parsing-an-sps-or-sas-file.Rmd └── setup_file_example.sps /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^CRAN-RELEASE$ 2 | ^\.github$ 3 | ^LICENSE\.md$ 4 | ^codecov\.yml$ 5 | ^.*\.Rproj$ 6 | ^\.Rproj\.user$ 7 | ^\.travis\.yml$ 8 | ^appveyor\.yml$ 9 | ^packrat/ 10 | ^\.Rprofile$ 11 | README.Rmd 12 | cran-comments.md 13 | ^docs$ 14 | ^CRAN-SUBMISSION$ 15 | revdep/ 16 | -------------------------------------------------------------------------------- /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, we pledge to respect all people who 4 | contribute through reporting issues, posting feature requests, updating documentation, 5 | submitting pull requests or patches, and other activities. 6 | 7 | We are committed to making participation in this project a harassment-free experience for 8 | everyone, regardless of level of experience, gender, gender identity and expression, 9 | sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion. 10 | 11 | Examples of unacceptable behavior by participants include the use of sexual language or 12 | imagery, derogatory comments or personal attacks, trolling, public or private harassment, 13 | insults, or other unprofessional conduct. 14 | 15 | Project maintainers have the right and responsibility to remove, edit, or reject comments, 16 | commits, code, wiki edits, issues, and other contributions that are not aligned to this 17 | Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed 18 | from the project team. 19 | 20 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by 21 | opening an issue or contacting one or more of the project maintainers. 22 | 23 | This Code of Conduct is adapted from the Contributor Covenant 24 | (http://contributor-covenant.org), version 1.0.0, available at 25 | http://contributor-covenant.org/version/1/0/0/ 26 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to asciiSetupReader 2 | 3 | This outlines how to propose a change to asciiSetupReader. For more detailed 4 | info about contributing to this, and other tidyverse packages, please see the 5 | [**development contributing guide**](https://rstd.io/tidy-contrib). 6 | 7 | ### Fixing typos 8 | 9 | Small typos or grammatical errors in documentation may be edited directly using 10 | the GitHub web interface, so long as the changes are made in the _source_ file. 11 | 12 | * YES: you edit a roxygen comment in a `.R` file below `R/`. 13 | * NO: you edit an `.Rd` file below `man/`. 14 | 15 | ### Prerequisites 16 | 17 | Before you make a substantial pull request, you should always file an issue and 18 | make sure someone from the team agrees that it’s a problem. If you’ve found a 19 | bug, create an associated issue and illustrate the bug with a minimal 20 | [reprex](https://www.tidyverse.org/help/#reprex). 21 | 22 | ### Pull request process 23 | 24 | * We recommend that you create a Git branch for each pull request (PR). 25 | * Look at the Travis and AppVeyor build status before and after making changes. 26 | The `README` should contain badges for any continuous integration services used 27 | by the package. 28 | * New code should follow the tidyverse [style guide](http://style.tidyverse.org). 29 | You can use the [styler](https://CRAN.R-project.org/package=styler) package to 30 | apply these styles, but please don't restyle code that has nothing to do with 31 | your PR. 32 | * We use [roxygen2](https://cran.r-project.org/package=roxygen2), with 33 | [Markdown syntax](https://cran.r-project.org/web/packages/roxygen2/vignettes/markdown.html), 34 | for documentation. 35 | * We use [testthat](https://cran.r-project.org/package=testthat). Contributions 36 | with test cases included are easier to accept. 37 | * For user-facing changes, add a bullet to the top of `NEWS.md` below the 38 | current development version header describing the changes made followed by your 39 | GitHub username, and links to relevant issue(s)/PR(s). 40 | 41 | ### Code of Conduct 42 | 43 | Please note that the asciiSetupReader project is released with a 44 | [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By contributing to this 45 | project you agree to abide by its terms. 46 | 47 | ### See tidyverse [development contributing guide](https://rstd.io/tidy-contrib) 48 | for further details. 49 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Please briefly describe your problem and what output you expect. If you have a question, please don't use this form. Instead, ask on or . 2 | 3 | Please include a minimal reproducible example (AKA a reprex). If you've never heard of a [reprex](http://reprex.tidyverse.org/) before, start by reading . 4 | 5 | --- 6 | 7 | Brief description of the problem 8 | 9 | ```r 10 | # insert reprex here 11 | ``` 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | packrat/lib*/ 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # R for travis: see documentation at https://docs.travis-ci.com/user/languages/r 2 | 3 | language: R 4 | sudo: false 5 | cache: packages 6 | notifications: 7 | email: 8 | on_failure: always 9 | 10 | 11 | on_failure: 12 | - ./travis-tool.sh dump_logs 13 | 14 | after_script: 15 | - ./travis-tool.sh dump_logs_by_extension "timings" 16 | - ./travis-tool.sh dump_sysinfo 17 | 18 | r_packages: 19 | - covr 20 | 21 | after_success: 22 | - Rscript -e 'library(covr); codecov()' 23 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Package 2 | Package: asciiSetupReader 3 | Title: Reads Fixed-Width ASCII Data Files (.txt or .dat) that 4 | Have Accompanying Setup Files (.sps or .sas) 5 | Version: 2.5.2 6 | Authors@R: 7 | person(given = "Jacob", 8 | family = "Kaplan", 9 | role = c("aut", "cre"), 10 | email = "jkkaplan6@gmail.com", 11 | comment = c(ORCID = "0000-0002-0601-0387")) 12 | Description: Lets you open a fixed-width ASCII file (.txt or 13 | .dat) that has an accompanying setup file (.sps or .sas). These file 14 | combinations are sometimes referred to as .txt+.sps, .txt+.sas, 15 | .dat+.sps, or .dat+.sas. This will only run in a txt-sps or txt-sas 16 | pair in which the setup file contains instructions to open that text 17 | file. It will NOT open other text files, .sav, .sas, or .por data 18 | files. Fixed-width ASCII files with setup files are common in older 19 | (pre-2000) government data. 20 | License: MIT + file LICENSE 21 | URL: https://github.com/jacobkap/asciiSetupReader 22 | BugReports: https://github.com/jacobkap/asciiSetupReader/issues 23 | Depends: 24 | R (>= 3.1.0) 25 | Imports: 26 | data.table, 27 | haven, 28 | readr, 29 | vroom, 30 | stringr, 31 | zoo, 32 | shiny (>= 0.13), 33 | miniUI (>= 0.1.1), 34 | rstudioapi (>= 0.5) 35 | Suggests: 36 | covr, 37 | knitr, 38 | rmarkdown, 39 | testthat (>= 2.1.0) 40 | VignetteBuilder: 41 | knitr 42 | Encoding: UTF-8 43 | Language: en-US 44 | LazyData: false 45 | RoxygenNote: 7.1.1 46 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2019 2 | COPYRIGHT HOLDER: Jacob Kaplan 3 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) 2019 Jacob Kaplan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(make_sps_setup) 4 | export(parse_setup) 5 | export(read_ascii_setup) 6 | export(read_ascii_setup_addin) 7 | export(sas_ascii_reader) 8 | export(spss_ascii_reader) 9 | import(data.table) 10 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # asciiSetupReader 2.5.2 2 | 3 | * Removes startup message 4 | 5 | # asciiSetupReader 2.5.1 6 | 7 | * Adds startup message 8 | 9 | # asciiSetupReader 2.5.0 10 | 11 | * In column names now replaces "<" with "_under_", ">" with "_over_", 12 | "$" with "_dollar_", "+" with "_plus_", "@" with "_at_". Previously 13 | these values would be replaced by "_". 14 | 15 | # asciiSetupReader 2.4.0 16 | 17 | * Adds functionality to handle "low thru" missing values. 18 | * "low thru" and "thru high" missing values are now less (more) than and equal 19 | to rather than just less (more) than the value. 20 | 21 | # asciiSetupReader 2.3.2 22 | 23 | * Fix bug on reading an atypical .sps file. 24 | 25 | # asciiSetupReader 2.3.1 26 | 27 | * Fix bug caused by `vroom` not handling embedded nulls. 28 | * Fix bug where code would run even if start column number > end column number, but would crash code later. 29 | * Fix bug where code wouldn't run if .sps setup file read MISSING VALUE rather than MISSING VALUES. 30 | * Fix bug when value label is "X thru highest value". Now will change all values >= X to be NA. 31 | 32 | 33 | # asciiSetupReader 2.3.0 34 | 35 | * Misc. bug fixes. 36 | * Change package to read in fixed-width files from `readr` to `vroom` to 37 | significantly increase read time. 38 | 39 | # asciiSetupReader 2.2.0 40 | 41 | * Adds an addin to use the `read_ascii_setup()` function interactively. This allows 42 | users to select every option in the popup window. 43 | 44 | # asciiSetupReader 2.1.0 45 | 46 | * Reorder list of value labels returned from `parse_setup` to be in same order 47 | as in setup file. 48 | * Misc. bug fixes and many new tests. 49 | 50 | # asciiSetupReader 2.0.2 51 | 52 | * Misc. bug fixes. 53 | 54 | # asciiSetupReader 2.0.1 55 | 56 | * Fix problem where package didn't work with dev version of Haven. 57 | 58 | # asciiSetupReader 2.0.0 59 | 60 | ## Major Changes 61 | 62 | * Adds a single function (`read_ascii_setup`) that will read in data for both 63 | .dat+.sps and .dat+.sas pairs. This is just a helper function that calls 64 | `spss_ascii_reader` or `sas_ascii_reader`. 65 | * Adds function to create sps setup files. 66 | * Adds capacity for .sas reader to handle missing values. 67 | * Adds a function for users to parse the setup file (.sps or .sas) and get results. 68 | An accompanying vignette explains this function. 69 | * Adds a function to make your own .sps files (not .sas yet). 70 | 71 | ## Minor Changes 72 | * Adds option to not coerce potentially numeric columns into numeric type. Useful in cases like dealing with Census FIPS codes that have leading zeros. 73 | * Miscellaneous bug fixes. 74 | * Fixes bug when missing values are an interval (e.g. -1 thru -8). 75 | 76 | # asciiSetupReader 1.4.0 77 | * Adds capacity to the SPSS reader to handle Missing Values. 78 | * Fixes bug where function fails if no value-labels are detected. 79 | + Applies both when setup file has no value-labels and if only select columns that have no value-labels. 80 | * Adds a huge number of tests. 81 | * Changes factor column to character columns. 82 | -------------------------------------------------------------------------------- /R/read_ascii_setup.R: -------------------------------------------------------------------------------- 1 | #' Read fixed-width ASCII file using SPSS or SAS Setup file. 2 | #' 3 | #' read_ascii_setup() is used when you need to 4 | #' read an fixed-width ASCII (text) file that comes with a setup file. 5 | #' The setup file provides instructions on how to create and name the columns, 6 | #' and fix the key-value pairs (sometimes called value labels). This is common 7 | #' in government data, particular data produced before 2010. 8 | #' 9 | #' @param data Name of the ASCII (.txt or .dat) file that contains the data. 10 | #' This file may be zipped with a file extension of .zip. 11 | #' @param setup_file Name of the SPSS or SAS setup file - should be a .sps or .sas (.txt also accepted as are these files in zipped format) 12 | #' @param use_value_labels If TRUE, fixes value labels of the data. e.g. If a 13 | #' column is "sex" and has values of 0 or 1, and the setup file says 0 = male 14 | #' and 1 = female, it will make that change. Using this parameter for enormous files may slow down the package considerably. 15 | #' @param use_clean_names If TRUE fixes column names from default column name in the 16 | #' setup file (e.g. V1, V2) to the descriptive label for the column provided in the file (e.g. age, sex, etc.). 17 | #' @param select_columns Specify which columns from the dataset you want. If 18 | #' NULL, will return all columns. Accepts the column number (e.g. 1:5), 19 | #' column name (e.g. V1, V2, etc.) or column label (e.g. VICTIM_NAME, CITY, 20 | #' etc.). 21 | #' @param coerce_numeric 22 | #' If TRUE (default) will make columns where all values can be made numeric 23 | #' into numeric columns. Useful as FALSE if variables have leading zeros - such 24 | #' as US Census FIPS codes. 25 | #' 26 | #' @return data.frame of the data from the ASCII file 27 | #' @export 28 | #' @examples 29 | #' # Text file is zipped to save space. 30 | #' dataset_name <- system.file("extdata", "example_data.zip", 31 | #' package = "asciiSetupReader") 32 | #' sps_name <- system.file("extdata", "example_setup.sps", 33 | #' package = "asciiSetupReader") 34 | #' 35 | #' \dontrun{ 36 | #' example <- read_ascii_setup(data = dataset_name, 37 | #' setup_file = sps_name) 38 | #' 39 | #' 40 | #' # Does not fix value labels 41 | #' example2 <- read_ascii_setup(data = dataset_name, 42 | #' setup_file = sps_name, use_value_labels = FALSE) 43 | #' 44 | #' # Keeps original column names 45 | #' example3 <- read_ascii_setup(data = dataset_name, 46 | #' setup_file = sps_name, use_clean_names = FALSE) 47 | #' } 48 | #' 49 | #' # Only returns the first 5 columns 50 | #' example4 <- read_ascii_setup(data = dataset_name, 51 | #' setup_file = sps_name, select_columns = 1:5) 52 | read_ascii_setup <- function(data, 53 | setup_file, 54 | use_value_labels = TRUE, 55 | use_clean_names = TRUE, 56 | select_columns = NULL, 57 | coerce_numeric = TRUE) { 58 | 59 | if (grepl(".sps(\\.zip)?$", setup_file)) { 60 | 61 | data <- spss_ascii_reader(dataset_name = data, 62 | sps_name = setup_file, 63 | value_label_fix = use_value_labels, 64 | real_names = use_clean_names, 65 | keep_columns = select_columns, 66 | coerce_numeric = coerce_numeric) 67 | } else { 68 | 69 | data <- sas_ascii_reader(dataset_name = data, 70 | sas_name = setup_file, 71 | value_label_fix = use_value_labels, 72 | real_names = use_clean_names, 73 | keep_columns = select_columns, 74 | coerce_numeric = coerce_numeric) 75 | } 76 | 77 | return(data) 78 | } 79 | -------------------------------------------------------------------------------- /R/read_ascii_setup_addin.R: -------------------------------------------------------------------------------- 1 | #' @title 2 | #' Launch an RStudio addin to select options for read_ascii_setup() 3 | #' @description 4 | #' Launch an RStudio addin to select options for read_ascii_setup(). 5 | #' @return 6 | #' read_ascii_setup() code to console with options based on user input 7 | #' @export 8 | #' @examples 9 | #' \dontrun{ 10 | #' read_ascii_setup_addin() 11 | #' } 12 | read_ascii_setup_addin <- function() { 13 | 14 | 15 | ui <- miniUI::miniPage( 16 | 17 | ## Your UI items go here. 18 | miniUI::miniTabstripPanel( 19 | miniUI::miniTabPanel(miniUI::gadgetTitleBar("Read fixed-width ASCII file using SPSS or SAS Setup file"), 20 | miniUI::miniContentPanel( 21 | shiny::fillRow( 22 | shiny::fillCol( 23 | shiny::textInput("new_data_name", label = shiny::h5("Select data name")), 24 | shiny::fluidRow(shiny::column(3, shiny::verbatimTextOutput("new_data_name"))), 25 | shiny::fileInput("data", label = shiny::h5("Data file input (.txt or .dat)")), 26 | shiny::fluidRow(shiny::column(4, shiny::verbatimTextOutput("data"))), 27 | shiny::fileInput("setup", label = shiny::h5("Setup file input (.sps or .sas)")), 28 | shiny::fluidRow(shiny::column(4, shiny::verbatimTextOutput("setup")))), 29 | shiny::fillCol( 30 | shiny::checkboxInput("value_labels", label = shiny::h5("Use value labels"), 31 | value = TRUE), 32 | shiny::checkboxInput("clean_names", label = shiny::h5("Use clean names"), 33 | value = TRUE), 34 | shiny::checkboxInput("coerce_numeric", label = shiny::h5("Coerce numeric columns"), 35 | value = TRUE), 36 | shiny::textInput("columns", label = shiny::h5("Select columns"), 37 | placeholder = "Optional - select specific columns") 38 | )) 39 | ) 40 | ) 41 | ) 42 | ) 43 | 44 | # Server code for the gadget. 45 | server <- function(input, output, session) { 46 | 47 | shiny::observeEvent(input$done, { 48 | shiny::req(input$data) 49 | shiny::req(input$setup) 50 | shiny::req(input$new_data_name) 51 | 52 | if (input$columns == "") { 53 | select_columns_temp <- "NULL" 54 | } else { 55 | select_columns_temp <- input$columns 56 | } 57 | 58 | data_path <- input$data$name 59 | data_path <- gsub("\\\\", "/", data_path) 60 | setup_path <- input$setup$name 61 | setup_path <- gsub("\\\\", "/", setup_path) 62 | 63 | rstudioapi::sendToConsole(paste0(input$new_data_name, 64 | " <- read_ascii_setup(data = '", 65 | data_path, 66 | "', setup_file = '", 67 | setup_path, 68 | "', use_value_labels = ", 69 | input$value_labels, 70 | ", use_clean_names = ", 71 | input$clean_names, 72 | ", select_columns = ", 73 | select_columns_temp, 74 | ", coerce_numeric = ", 75 | input$coerce_numeric, ")")) 76 | 77 | shiny::stopApp() 78 | }) 79 | } 80 | 81 | # Use a modal dialog as a viewr. 82 | viewer <- shiny::dialogViewer("Ascii Setup Reader") 83 | shiny::runGadget(ui, server, viewer = viewer) 84 | } 85 | -------------------------------------------------------------------------------- /R/sas.R: -------------------------------------------------------------------------------- 1 | #' Read fixed-width ASCII file using SAS Setup file. 2 | #' 3 | #' sas_ascii_reader() and spss_ascii_reader() are used when you need to 4 | #' read an fixed-width ASCII (text) file that comes with a setup file. These file 5 | #' combinations are sometimes referred to as .txt+.sps, .txt+.sas, 6 | #' .dat+.sps, or .dat+.sas. 7 | #' The setup file provides instructions on how to create and name the columns, 8 | #' and fix the key-value pairs (sometimes called value labels). This is common 9 | #' in government data, particular data produced before 2010. 10 | #' 11 | #' @family ASCII Reader functions 12 | #' @seealso \code{\link{spss_ascii_reader}} For using an SPSS setup file 13 | #' 14 | #' @param sas_name Name of the SAS Setup file - should be a .sas or .txt file. 15 | #' @inheritParams spss_ascii_reader 16 | #' @export 17 | #' @examples 18 | #' # Text file is zipped to save space. 19 | #' dataset_name <- system.file("extdata", "example_data.zip", 20 | #' package = "asciiSetupReader") 21 | #' sas_name <- system.file("extdata", "example_setup.sas", 22 | #' package = "asciiSetupReader") 23 | #' 24 | #' \dontrun{ 25 | #' example <- sas_ascii_reader(dataset_name = dataset_name, 26 | #' sas_name = sas_name) 27 | #' 28 | #' 29 | #' # Does not fix value labels 30 | #' example2 <- sas_ascii_reader(dataset_name = dataset_name, 31 | #' sas_name = sas_name, value_label_fix = FALSE) 32 | #' 33 | #' # Keeps original column names 34 | #' example3 <- sas_ascii_reader(dataset_name = dataset_name, 35 | #' sas_name = sas_name, real_names = FALSE) 36 | #' 37 | #' } 38 | #' # Only returns the first 5 columns 39 | #' example <- sas_ascii_reader(dataset_name = dataset_name, 40 | #' sas_name = sas_name, keep_columns = 1:5) 41 | #' 42 | sas_ascii_reader <- function(dataset_name, 43 | sas_name, 44 | value_label_fix = TRUE, 45 | real_names = TRUE, 46 | keep_columns = NULL, 47 | coerce_numeric = TRUE) { 48 | 49 | # .Deprecated("read_ascii_setup") 50 | 51 | stopifnot(is.character(dataset_name), length(dataset_name) == 1, 52 | is.character(sas_name), length(sas_name) == 1, 53 | is.logical(value_label_fix), length(value_label_fix) == 1, 54 | is.logical(real_names), length(real_names) == 1) 55 | 56 | 57 | # SAS setup 58 | setup <- parse_setup(sas_name) 59 | setup$setup <- selected_columns(keep_columns, setup$setup) 60 | 61 | 62 | 63 | 64 | # Reads in Data File ------------------------------------------------------ 65 | data <- read_data(dataset_name, setup) 66 | 67 | data <- fix_value_labels(data, setup, value_label_fix) 68 | 69 | 70 | 71 | data <- fix_names_missing_numeric(data, 72 | setup, 73 | missing, 74 | real_names, 75 | coerce_numeric) 76 | return(data) 77 | } 78 | -------------------------------------------------------------------------------- /R/spss.R: -------------------------------------------------------------------------------- 1 | #' Read fixed-width ASCII file using SPSS Setup file. 2 | #' 3 | #' spss_ascii_reader() and sas_ascii_reader() are used when you need to 4 | #' read an fixed-width ASCII (text) file that comes with a setup file. 5 | #' These file combinations are sometimes referred to as .txt+.sps, .txt+.sas, 6 | #' .dat+.sps, or .dat+.sas. 7 | #' The setup file provides instructions on how to create and name the columns, 8 | #' and fix the key-value pairs (sometimes called value labels). This is common 9 | #' in government data, particular data produced before 2010. 10 | #' 11 | #' @family ASCII Reader functions 12 | #' @seealso \code{\link{sas_ascii_reader}} For using an SAS setup file 13 | #' 14 | #' @param dataset_name Name of the ASCII (.txt) file that contains the data. 15 | #' This file may be zipped with a file extension of .zip. 16 | #' @param sps_name Name of the SPSS Setup file - should be a .sps or .txt 17 | #' (zipped text files also work) file. 18 | #' @param value_label_fix If TRUE, fixes value labels of the data. e.g. If a 19 | #' column is "sex" and has values of 0 or 1, and the setup file says 0 = male 20 | #' and 1 = female, it will make that change. The reader is much faster is this 21 | #' parameter is FALSE. 22 | #' @param real_names If TRUE fixes column names from default column name in the 23 | #' SPSS setup file (e.g. V1, V2) to the name is says the column is called 24 | #' (e.g. age, sex, etc.). 25 | #' @param keep_columns Specify which columns from the dataset you want. If 26 | #' NULL, will return all columns. Accepts the column number (e.g. 1:5), 27 | #' column name (e.g. V1, V2, etc.) or column label (e.g. VICTIM_NAME, CITY, 28 | #' etc.). 29 | #' @param coerce_numeric 30 | #' If TRUE (default) will make columns where all values can be made numeric 31 | #' into numeric columns.Useful as FALSE if variables have leading zeros - such 32 | #' as US Census FIPS codes. 33 | #' 34 | #' @return Data.frame of the data from the ASCII file 35 | #' @export 36 | #' @examples 37 | #' # Text file is zipped to save space. 38 | #' dataset_name <- system.file("extdata", "example_data.zip", 39 | #' package = "asciiSetupReader") 40 | #' sps_name <- system.file("extdata", "example_setup.sps", 41 | #' package = "asciiSetupReader") 42 | #' 43 | #' \dontrun{ 44 | #' example <- spss_ascii_reader(dataset_name = dataset_name, 45 | #' sps_name = sps_name) 46 | #' 47 | #' 48 | #' # Does not fix value labels 49 | #' example2 <- spss_ascii_reader(dataset_name = dataset_name, 50 | #' sps_name = sps_name, value_label_fix = FALSE) 51 | #' 52 | #' # Keeps original column names 53 | #' example3 <- spss_ascii_reader(dataset_name = dataset_name, 54 | #' sps_name = sps_name, real_names = FALSE) 55 | #' 56 | #' } 57 | #' # Only returns the first 5 columns 58 | #' example4 <- spss_ascii_reader(dataset_name = dataset_name, 59 | #' sps_name = sps_name, keep_columns = 1:5) 60 | #' 61 | spss_ascii_reader <- function(dataset_name, 62 | sps_name, 63 | value_label_fix = TRUE, 64 | real_names = TRUE, 65 | keep_columns = NULL, 66 | coerce_numeric = TRUE) { 67 | 68 | # .Deprecated("read_ascii_setup") 69 | 70 | stopifnot(is.character(dataset_name), length(dataset_name) == 1, 71 | is.character(sps_name), length(sps_name) == 1, 72 | is.logical(value_label_fix), length(value_label_fix) == 1, 73 | is.logical(real_names), length(real_names) == 1) 74 | 75 | setup <- parse_setup(sps_name) 76 | setup$setup <- selected_columns(keep_columns, setup$setup) 77 | 78 | data <- read_data(dataset_name, setup) 79 | 80 | 81 | data <- fix_value_labels(data, setup, value_label_fix) 82 | 83 | 84 | data <- fix_names_missing_numeric(data, 85 | setup, 86 | missing, 87 | real_names, 88 | coerce_numeric) 89 | 90 | return(data) 91 | } 92 | -------------------------------------------------------------------------------- /R/utils-data-table.R: -------------------------------------------------------------------------------- 1 | # data.table is generally careful to minimize the scope for namespace 2 | # conflicts (i.e., functions with the same name as in other packages); 3 | # a more conservative approach using @importFrom should be careful to 4 | # import any needed data.table special symbols as well, e.g., if you 5 | # run DT[ , .N, by='grp'] in your package, you'll need to add 6 | # @importFrom data.table .N to prevent the NOTE from R CMD check. 7 | # See ?data.table::`special-symbols` for the list of such symbols 8 | # data.table defines; see the 'Importing data.table' vignette for more 9 | # advice (vignette('datatable-importing', 'data.table')). 10 | # 11 | #' @import data.table 12 | NULL 13 | -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | --- 4 | ```{r, include = FALSE} 5 | knitr::opts_chunk$set( 6 | collapse = TRUE, 7 | comment = "#>", 8 | fig.path = "man/figures/README-", 9 | out.width = "100%" 10 | ) 11 | ``` 12 | 13 | # asciiSetupReader 14 | 15 | 16 | [![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/asciiSetupReader)](https://cran.r-project.org/package=asciiSetupReader) 17 | [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/jacobkap/asciiSetupReader?branch=master&svg=true)](https://ci.appveyor.com/project/jacobkap/asciiSetupReader) 18 | [![Coverage status](https://codecov.io/gh/jacobkap/asciiSetupReader/branch/master/graph/badge.svg)](https://app.codecov.io/github/jacobkap/asciiSetupReader?branch=master) 19 | [![](http://cranlogs.r-pkg.org/badges/grand-total/asciiSetupReader?color=blue)](https://cran.r-project.org/package=asciiSetupReader) 20 | [![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html) 21 | 22 | 23 | ## Overview 24 | 25 | Some (usually older) data sets are only available in fixed-width ASCII files (.txt or .dat) that have an .sps (SPSS) or .sas (SAS) setup file explaining to the software how to read that file. These file combinations are sometimes referred to as .txt+.sps, .txt+.sas, .dat+.sps, .dat+.sas. This package allows you to read in the data if you have both the fixed-width file and its accompanying setup file. 26 | 27 | ## Installation 28 | 29 | ``` r 30 | To install this package, use the code 31 | install.packages("asciiSetupReader") 32 | 33 | 34 | # The development version is available on Github. 35 | # install.packages("devtools") 36 | devtools::install_github("jacobkap/asciiSetupReader") 37 | ``` 38 | 39 | ## Usage 40 | 41 | The parameters `data` and `setup_file` are the only ones requires to run the package though three optional parameters allow you to customize results. 42 | 43 | `data` - A string containing the name of the data file 44 | 45 | `setup_file` - A string containing the name of the setup file 46 | 47 | Both files must be in your working directory or the string must contain the path to the file. Below is an example of reading in the example dataset - the original data and setup files can be found [here](https://www.icpsr.umich.edu/icpsrweb/NACJD/studies/9327?q=&restrictionType%5B0%5D=Public+Use&classification%5B0%5D=NACJD.IX.*&dataFormat%5B0%5D=SPSS). 48 | 49 | Please note that I am only using `system.file()` here so the vignette builds in the package even not on my own computer. You will not use this in the function. Instead you'd simply input `data = "example_data.zip"` and `setup_file = "example_setup.sps"`. The data file does not have to be in a zip folder, it is only in a zip folder here to reduce the size of this package. In most cases it will be a .dat or a .txt file. 50 | 51 | ```{r} 52 | data <- system.file("extdata", "example_data.zip", 53 | package = "asciiSetupReader") 54 | setup_file <- system.file("extdata", "example_setup.sps", 55 | package = "asciiSetupReader") 56 | 57 | example <- asciiSetupReader::read_ascii_setup(data = data, 58 | setup_file = setup_file) 59 | example[1:6, 1:4] # Look at first 6 rows and first 4 columns 60 | ``` 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # asciiSetupReader 3 | 4 | 5 | 6 | [![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/asciiSetupReader)](https://cran.r-project.org/package=asciiSetupReader) 7 | [![AppVeyor Build 8 | Status](https://ci.appveyor.com/api/projects/status/github/jacobkap/asciiSetupReader?branch=master&svg=true)](https://ci.appveyor.com/project/jacobkap/asciiSetupReader) 9 | [![Coverage 10 | status](https://codecov.io/gh/jacobkap/asciiSetupReader/branch/master/graph/badge.svg)](https://app.codecov.io/github/jacobkap/asciiSetupReader?branch=master) 11 | [![](http://cranlogs.r-pkg.org/badges/grand-total/asciiSetupReader?color=blue)](https://cran.r-project.org/package=asciiSetupReader) 12 | [![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html) 13 | 14 | 15 | ## Overview 16 | 17 | Some (usually older) data sets are only available in fixed-width ASCII 18 | files (.txt or .dat) that have an .sps (SPSS) or .sas (SAS) setup file 19 | explaining to the software how to read that file. These file 20 | combinations are sometimes referred to as .txt+.sps, .txt+.sas, 21 | .dat+.sps, .dat+.sas. This package allows you to read in the data if you 22 | have both the fixed-width file and its accompanying setup file. 23 | 24 | ## Installation 25 | 26 | ``` r 27 | To install this package, use the code 28 | install.packages("asciiSetupReader") 29 | 30 | 31 | # The development version is available on Github. 32 | # install.packages("devtools") 33 | devtools::install_github("jacobkap/asciiSetupReader") 34 | ``` 35 | 36 | ## Usage 37 | 38 | The parameters `data` and `setup_file` are the only ones requires to run 39 | the package though three optional parameters allow you to customize 40 | results. 41 | 42 | `data` - A string containing the name of the data file 43 | 44 | `setup_file` - A string containing the name of the setup file 45 | 46 | Both files must be in your working directory or the string must contain 47 | the path to the file. Below is an example of reading in the example 48 | dataset - the original data and setup files can be found 49 | [here](https://www.icpsr.umich.edu/icpsrweb/NACJD/studies/9327?q=&restrictionType%5B0%5D=Public+Use&classification%5B0%5D=NACJD.IX.*&dataFormat%5B0%5D=SPSS). 50 | 51 | Please note that I am only using `system.file()` here so the vignette 52 | builds in the package even not on my own computer. You will not use this 53 | in the function. Instead you’d simply input `data = "example_data.zip"` 54 | and `setup_file = "example_setup.sps"`. The data file does not have to 55 | be in a zip folder, it is only in a zip folder here to reduce the size 56 | of this package. In most cases it will be a .dat or a .txt file. 57 | 58 | ``` r 59 | data <- system.file("extdata", "example_data.zip", 60 | package = "asciiSetupReader") 61 | setup_file <- system.file("extdata", "example_setup.sps", 62 | package = "asciiSetupReader") 63 | 64 | example <- asciiSetupReader::read_ascii_setup(data = data, 65 | setup_file = setup_file) 66 | example[1:6, 1:4] # Look at first 6 rows and first 4 columns 67 | #> IDENTIFIER_CODE NUMERIC_STATE_CODE ORI_CODE GROUP 68 | #> 1 SHR master file Alabama AL00112 Cit 50,000-99,999 69 | #> 2 SHR master file Alabama AL00112 Cit 50,000-99,999 70 | #> 3 SHR master file Alabama AL00112 Cit 50,000-99,999 71 | #> 4 SHR master file Arizona AZ00189 Cit < 2,500 72 | #> 5 SHR master file Arizona AZ00189 Cit < 2,500 73 | #> 6 SHR master file Arizona AZ00189 Cit < 2,500 74 | ``` 75 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # DO NOT CHANGE the "init" and "install" sections below 2 | 3 | # Download script file from GitHub 4 | init: 5 | ps: | 6 | $ErrorActionPreference = "Stop" 7 | Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1" 8 | Import-Module '..\appveyor-tool.ps1' 9 | 10 | install: 11 | ps: Bootstrap 12 | 13 | environment: 14 | USE_RTOOLS: true 15 | 16 | cache: 17 | # - C:\RLibrary 18 | 19 | # Adapt as necessary starting from here 20 | 21 | build_script: 22 | - travis-tool.sh install_deps 23 | 24 | test_script: 25 | - travis-tool.sh run_tests 26 | 27 | on_failure: 28 | - 7z a failure.zip *.Rcheck\* 29 | - appveyor PushArtifact failure.zip 30 | 31 | artifacts: 32 | - path: '*.Rcheck\**\*.log' 33 | name: Logs 34 | 35 | - path: '*.Rcheck\**\*.out' 36 | name: Logs 37 | 38 | - path: '*.Rcheck\**\*.fail' 39 | name: Logs 40 | 41 | - path: '*.Rcheck\**\*.Rout' 42 | name: Logs 43 | 44 | - path: '\*_*.tar.gz' 45 | name: Bits 46 | 47 | - path: '\*_*.zip' 48 | name: Bits 49 | -------------------------------------------------------------------------------- /asciiReader.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: No 4 | SaveWorkspace: No 5 | AlwaysSaveHistory: No 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageRoxygenize: rd,collate,vignette 21 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | 3 | coverage: 4 | status: 5 | project: 6 | default: 7 | target: auto 8 | threshold: 1% 9 | patch: 10 | default: 11 | target: auto 12 | threshold: 1% 13 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | ## Test environments 2 | 3 | * local Windows install, R 4.2.1 4 | * Rhub 5 | + linux (R-devel) 6 | + macos-arm64 (R-devel) 7 | + macos (R-devel) 8 | + windows (R-devel) 9 | * win-builder (devel) 10 | 11 | ## R CMD check results 12 | 13 | There were no ERRORs or WARNINGs or NOTES. 14 | 15 | ## Reverse dependencies 16 | 17 | There is 1 reverse dependency. revdepcheck::revdep_check() returns OK for all 1. 18 | 19 | -------------------------------------------------------------------------------- /docs/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Page not found (404) • asciiSetupReader 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
62 |
63 | 123 | 124 | 125 | 126 |
127 | 128 |
129 |
130 | 133 | 134 | Content not found. Please use links in the navbar. 135 | 136 |
137 | 138 | 143 | 144 |
145 | 146 | 147 | 148 |
149 | 152 | 153 |
154 |

Site built with pkgdown 1.6.1.

155 |
156 | 157 |
158 |
159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | -------------------------------------------------------------------------------- /docs/ISSUE_TEMPLATE.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | NA • asciiSetupReader 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
62 |
63 | 123 | 124 | 125 | 126 |
127 | 128 |
129 |
130 | 133 | 134 | 135 |

Please briefly describe your problem and what output you expect. If you have a question, please don’t use this form. Instead, ask on https://stackoverflow.com/ or https://community.rstudio.com/.

136 |

Please include a minimal reproducible example (AKA a reprex). If you’ve never heard of a reprex before, start by reading https://www.tidyverse.org/help/#reprex.

137 |
138 |

Brief description of the problem

139 |
140 | # insert reprex here
141 | 142 | 143 |
144 | 145 | 150 | 151 |
152 | 153 | 154 | 155 |
156 | 159 | 160 |
161 |

Site built with pkgdown 1.6.1.

162 |
163 | 164 |
165 |
166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | -------------------------------------------------------------------------------- /docs/LICENSE-text.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | License • asciiSetupReader 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
62 |
63 | 123 | 124 | 125 | 126 |
127 | 128 |
129 |
130 | 133 | 134 |
YEAR: 2019
135 | COPYRIGHT HOLDER: Jacob Kaplan
136 | 
137 | 138 |
139 | 140 | 145 | 146 |
147 | 148 | 149 | 150 |
151 | 154 | 155 |
156 |

Site built with pkgdown 1.6.1.

157 |
158 | 159 |
160 |
161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | -------------------------------------------------------------------------------- /docs/LICENSE.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | MIT License • asciiSetupReader 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
62 |
63 | 123 | 124 | 125 | 126 |
127 | 128 |
129 |
130 | 133 | 134 |
135 | 136 |

Copyright (c) 2019 Jacob Kaplan

137 |

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

138 |

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

139 |

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

140 |
141 | 142 |
143 | 144 | 149 | 150 |
151 | 152 | 153 | 154 |
155 | 158 | 159 |
160 |

Site built with pkgdown 1.6.1.

161 |
162 | 163 |
164 |
165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | -------------------------------------------------------------------------------- /docs/articles/Introduction_to_asciiSetupReader_files/accessible-code-block-0.0.1/empty-anchor.js: -------------------------------------------------------------------------------- 1 | // Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> 2 | // v0.0.1 3 | // Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. 4 | 5 | document.addEventListener('DOMContentLoaded', function() { 6 | const codeList = document.getElementsByClassName("sourceCode"); 7 | for (var i = 0; i < codeList.length; i++) { 8 | var linkList = codeList[i].getElementsByTagName('a'); 9 | for (var j = 0; j < linkList.length; j++) { 10 | if (linkList[j].innerHTML === "") { 11 | linkList[j].setAttribute('aria-hidden', 'true'); 12 | } 13 | } 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /docs/articles/Introduction_to_asciiSetupReader_files/elevate-section-attrs-2.0/elevate-section-attrs.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | $("div.section[class*='level'], section[class*='level']").each(function(i, el) { 3 | var $section = $(el); 4 | var $header = $section.children().filter(":header").first(); 5 | if ($header.length === 0) return; 6 | var attrs = $header[0].attributes; 7 | for (var a = 0; a < attrs.length; a++) { 8 | var nm = attrs[a].name; 9 | var val = attrs[a].value; 10 | if (nm === "class") { 11 | $section.addClass(val); 12 | $header.removeClass(val); 13 | continue; 14 | } 15 | $section.attr(nm, val); 16 | $header.attr(nm, null); 17 | } 18 | }); 19 | }); 20 | 21 | -------------------------------------------------------------------------------- /docs/articles/Introduction_to_asciiSetupReader_files/header-attrs-2.3.2/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/Introduction_to_asciiSetupReader_files/header-attrs-2.4/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/Introduction_to_asciiSetupReader_files/header-attrs-2.6/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/Introduction_to_asciiSetupReader_files/header-attrs-2.7/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Articles • asciiSetupReader 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
62 |
63 | 123 | 124 | 125 | 126 |
127 | 128 |
129 |
130 | 133 | 134 |
135 |

All vignettes

136 |

137 | 138 |
139 |
Introduction to asciiSetupReader
140 |
141 |
Making an .sps file
142 |
143 |
Parsing an .sps or .sas file
144 |
145 |
146 |
147 |
148 |
149 | 150 | 151 |
152 | 155 | 156 |
157 |

Site built with pkgdown 1.6.1.

158 |
159 | 160 |
161 |
162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | -------------------------------------------------------------------------------- /docs/articles/making-an-sps-file_files/accessible-code-block-0.0.1/empty-anchor.js: -------------------------------------------------------------------------------- 1 | // Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> 2 | // v0.0.1 3 | // Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. 4 | 5 | document.addEventListener('DOMContentLoaded', function() { 6 | const codeList = document.getElementsByClassName("sourceCode"); 7 | for (var i = 0; i < codeList.length; i++) { 8 | var linkList = codeList[i].getElementsByTagName('a'); 9 | for (var j = 0; j < linkList.length; j++) { 10 | if (linkList[j].innerHTML === "") { 11 | linkList[j].setAttribute('aria-hidden', 'true'); 12 | } 13 | } 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /docs/articles/making-an-sps-file_files/elevate-section-attrs-2.0/elevate-section-attrs.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | $("div.section[class*='level'], section[class*='level']").each(function(i, el) { 3 | var $section = $(el); 4 | var $header = $section.children().filter(":header").first(); 5 | if ($header.length === 0) return; 6 | var attrs = $header[0].attributes; 7 | for (var a = 0; a < attrs.length; a++) { 8 | var nm = attrs[a].name; 9 | var val = attrs[a].value; 10 | if (nm === "class") { 11 | $section.addClass(val); 12 | $header.removeClass(val); 13 | continue; 14 | } 15 | $section.attr(nm, val); 16 | $header.attr(nm, null); 17 | } 18 | }); 19 | }); 20 | 21 | -------------------------------------------------------------------------------- /docs/articles/making-an-sps-file_files/header-attrs-2.3.2/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/making-an-sps-file_files/header-attrs-2.4/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/making-an-sps-file_files/header-attrs-2.6/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/making-an-sps-file_files/header-attrs-2.7/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/making_a_sps_setup_file_files/figure-html/unnamed-chunk-1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/docs/articles/making_a_sps_setup_file_files/figure-html/unnamed-chunk-1-1.png -------------------------------------------------------------------------------- /docs/articles/making_a_sps_setup_file_files/figure-html/unnamed-chunk-1-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/docs/articles/making_a_sps_setup_file_files/figure-html/unnamed-chunk-1-2.png -------------------------------------------------------------------------------- /docs/articles/making_an_sps_setup_file_files/figure-html/unnamed-chunk-1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/docs/articles/making_an_sps_setup_file_files/figure-html/unnamed-chunk-1-1.png -------------------------------------------------------------------------------- /docs/articles/making_an_sps_setup_file_files/figure-html/unnamed-chunk-1-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/docs/articles/making_an_sps_setup_file_files/figure-html/unnamed-chunk-1-2.png -------------------------------------------------------------------------------- /docs/articles/parsing-an-sps-or-sas-file_files/accessible-code-block-0.0.1/empty-anchor.js: -------------------------------------------------------------------------------- 1 | // Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> 2 | // v0.0.1 3 | // Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. 4 | 5 | document.addEventListener('DOMContentLoaded', function() { 6 | const codeList = document.getElementsByClassName("sourceCode"); 7 | for (var i = 0; i < codeList.length; i++) { 8 | var linkList = codeList[i].getElementsByTagName('a'); 9 | for (var j = 0; j < linkList.length; j++) { 10 | if (linkList[j].innerHTML === "") { 11 | linkList[j].setAttribute('aria-hidden', 'true'); 12 | } 13 | } 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /docs/articles/parsing-an-sps-or-sas-file_files/elevate-section-attrs-2.0/elevate-section-attrs.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | $("div.section[class*='level'], section[class*='level']").each(function(i, el) { 3 | var $section = $(el); 4 | var $header = $section.children().filter(":header").first(); 5 | if ($header.length === 0) return; 6 | var attrs = $header[0].attributes; 7 | for (var a = 0; a < attrs.length; a++) { 8 | var nm = attrs[a].name; 9 | var val = attrs[a].value; 10 | if (nm === "class") { 11 | $section.addClass(val); 12 | $header.removeClass(val); 13 | continue; 14 | } 15 | $section.attr(nm, val); 16 | $header.attr(nm, null); 17 | } 18 | }); 19 | }); 20 | 21 | -------------------------------------------------------------------------------- /docs/articles/parsing-an-sps-or-sas-file_files/header-attrs-2.3.2/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/parsing-an-sps-or-sas-file_files/header-attrs-2.4/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/parsing-an-sps-or-sas-file_files/header-attrs-2.6/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/parsing-an-sps-or-sas-file_files/header-attrs-2.7/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/parsing_a_sps_setup_file_files/figure-html/unnamed-chunk-1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/docs/articles/parsing_a_sps_setup_file_files/figure-html/unnamed-chunk-1-1.png -------------------------------------------------------------------------------- /docs/articles/parsing_a_sps_setup_file_files/figure-html/unnamed-chunk-1-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/docs/articles/parsing_a_sps_setup_file_files/figure-html/unnamed-chunk-1-2.png -------------------------------------------------------------------------------- /docs/authors.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Authors • asciiSetupReader 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
62 |
63 | 123 | 124 | 125 | 126 |
127 | 128 |
129 |
130 | 133 | 134 |
    135 |
  • 136 |

    Jacob Kaplan. Author, maintainer. 137 |

    138 |
  • 139 |
140 | 141 |
142 | 143 |
144 | 145 | 146 | 147 |
148 | 151 | 152 |
153 |

Site built with pkgdown 1.6.1.

154 |
155 | 156 |
157 |
158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /docs/bootstrap-toc.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | 6 | /* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ 7 | 8 | /* All levels of nav */ 9 | nav[data-toggle='toc'] .nav > li > a { 10 | display: block; 11 | padding: 4px 20px; 12 | font-size: 13px; 13 | font-weight: 500; 14 | color: #767676; 15 | } 16 | nav[data-toggle='toc'] .nav > li > a:hover, 17 | nav[data-toggle='toc'] .nav > li > a:focus { 18 | padding-left: 19px; 19 | color: #563d7c; 20 | text-decoration: none; 21 | background-color: transparent; 22 | border-left: 1px solid #563d7c; 23 | } 24 | nav[data-toggle='toc'] .nav > .active > a, 25 | nav[data-toggle='toc'] .nav > .active:hover > a, 26 | nav[data-toggle='toc'] .nav > .active:focus > a { 27 | padding-left: 18px; 28 | font-weight: bold; 29 | color: #563d7c; 30 | background-color: transparent; 31 | border-left: 2px solid #563d7c; 32 | } 33 | 34 | /* Nav: second level (shown on .active) */ 35 | nav[data-toggle='toc'] .nav .nav { 36 | display: none; /* Hide by default, but at >768px, show it */ 37 | padding-bottom: 10px; 38 | } 39 | nav[data-toggle='toc'] .nav .nav > li > a { 40 | padding-top: 1px; 41 | padding-bottom: 1px; 42 | padding-left: 30px; 43 | font-size: 12px; 44 | font-weight: normal; 45 | } 46 | nav[data-toggle='toc'] .nav .nav > li > a:hover, 47 | nav[data-toggle='toc'] .nav .nav > li > a:focus { 48 | padding-left: 29px; 49 | } 50 | nav[data-toggle='toc'] .nav .nav > .active > a, 51 | nav[data-toggle='toc'] .nav .nav > .active:hover > a, 52 | nav[data-toggle='toc'] .nav .nav > .active:focus > a { 53 | padding-left: 28px; 54 | font-weight: 500; 55 | } 56 | 57 | /* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ 58 | nav[data-toggle='toc'] .nav > .active > ul { 59 | display: block; 60 | } 61 | -------------------------------------------------------------------------------- /docs/bootstrap-toc.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | (function() { 6 | 'use strict'; 7 | 8 | window.Toc = { 9 | helpers: { 10 | // return all matching elements in the set, or their descendants 11 | findOrFilter: function($el, selector) { 12 | // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/ 13 | // http://stackoverflow.com/a/12731439/358804 14 | var $descendants = $el.find(selector); 15 | return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])'); 16 | }, 17 | 18 | generateUniqueIdBase: function(el) { 19 | var text = $(el).text(); 20 | var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-'); 21 | return anchor || el.tagName.toLowerCase(); 22 | }, 23 | 24 | generateUniqueId: function(el) { 25 | var anchorBase = this.generateUniqueIdBase(el); 26 | for (var i = 0; ; i++) { 27 | var anchor = anchorBase; 28 | if (i > 0) { 29 | // add suffix 30 | anchor += '-' + i; 31 | } 32 | // check if ID already exists 33 | if (!document.getElementById(anchor)) { 34 | return anchor; 35 | } 36 | } 37 | }, 38 | 39 | generateAnchor: function(el) { 40 | if (el.id) { 41 | return el.id; 42 | } else { 43 | var anchor = this.generateUniqueId(el); 44 | el.id = anchor; 45 | return anchor; 46 | } 47 | }, 48 | 49 | createNavList: function() { 50 | return $(''); 51 | }, 52 | 53 | createChildNavList: function($parent) { 54 | var $childList = this.createNavList(); 55 | $parent.append($childList); 56 | return $childList; 57 | }, 58 | 59 | generateNavEl: function(anchor, text) { 60 | var $a = $(''); 61 | $a.attr('href', '#' + anchor); 62 | $a.text(text); 63 | var $li = $('
  • '); 64 | $li.append($a); 65 | return $li; 66 | }, 67 | 68 | generateNavItem: function(headingEl) { 69 | var anchor = this.generateAnchor(headingEl); 70 | var $heading = $(headingEl); 71 | var text = $heading.data('toc-text') || $heading.text(); 72 | return this.generateNavEl(anchor, text); 73 | }, 74 | 75 | // Find the first heading level (`

    `, then `

    `, etc.) that has more than one element. Defaults to 1 (for `

    `). 76 | getTopLevel: function($scope) { 77 | for (var i = 1; i <= 6; i++) { 78 | var $headings = this.findOrFilter($scope, 'h' + i); 79 | if ($headings.length > 1) { 80 | return i; 81 | } 82 | } 83 | 84 | return 1; 85 | }, 86 | 87 | // returns the elements for the top level, and the next below it 88 | getHeadings: function($scope, topLevel) { 89 | var topSelector = 'h' + topLevel; 90 | 91 | var secondaryLevel = topLevel + 1; 92 | var secondarySelector = 'h' + secondaryLevel; 93 | 94 | return this.findOrFilter($scope, topSelector + ',' + secondarySelector); 95 | }, 96 | 97 | getNavLevel: function(el) { 98 | return parseInt(el.tagName.charAt(1), 10); 99 | }, 100 | 101 | populateNav: function($topContext, topLevel, $headings) { 102 | var $context = $topContext; 103 | var $prevNav; 104 | 105 | var helpers = this; 106 | $headings.each(function(i, el) { 107 | var $newNav = helpers.generateNavItem(el); 108 | var navLevel = helpers.getNavLevel(el); 109 | 110 | // determine the proper $context 111 | if (navLevel === topLevel) { 112 | // use top level 113 | $context = $topContext; 114 | } else if ($prevNav && $context === $topContext) { 115 | // create a new level of the tree and switch to it 116 | $context = helpers.createChildNavList($prevNav); 117 | } // else use the current $context 118 | 119 | $context.append($newNav); 120 | 121 | $prevNav = $newNav; 122 | }); 123 | }, 124 | 125 | parseOps: function(arg) { 126 | var opts; 127 | if (arg.jquery) { 128 | opts = { 129 | $nav: arg 130 | }; 131 | } else { 132 | opts = arg; 133 | } 134 | opts.$scope = opts.$scope || $(document.body); 135 | return opts; 136 | } 137 | }, 138 | 139 | // accepts a jQuery object, or an options object 140 | init: function(opts) { 141 | opts = this.helpers.parseOps(opts); 142 | 143 | // ensure that the data attribute is in place for styling 144 | opts.$nav.attr('data-toggle', 'toc'); 145 | 146 | var $topContext = this.helpers.createChildNavList(opts.$nav); 147 | var topLevel = this.helpers.getTopLevel(opts.$scope); 148 | var $headings = this.helpers.getHeadings(opts.$scope, topLevel); 149 | this.helpers.populateNav($topContext, topLevel, $headings); 150 | } 151 | }; 152 | 153 | $(function() { 154 | $('nav[data-toggle="toc"]').each(function(i, el) { 155 | var $nav = $(el); 156 | Toc.init($nav); 157 | }); 158 | }); 159 | })(); 160 | -------------------------------------------------------------------------------- /docs/docsearch.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | // register a handler to move the focus to the search bar 4 | // upon pressing shift + "/" (i.e. "?") 5 | $(document).on('keydown', function(e) { 6 | if (e.shiftKey && e.keyCode == 191) { 7 | e.preventDefault(); 8 | $("#search-input").focus(); 9 | } 10 | }); 11 | 12 | $(document).ready(function() { 13 | // do keyword highlighting 14 | /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ 15 | var mark = function() { 16 | 17 | var referrer = document.URL ; 18 | var paramKey = "q" ; 19 | 20 | if (referrer.indexOf("?") !== -1) { 21 | var qs = referrer.substr(referrer.indexOf('?') + 1); 22 | var qs_noanchor = qs.split('#')[0]; 23 | var qsa = qs_noanchor.split('&'); 24 | var keyword = ""; 25 | 26 | for (var i = 0; i < qsa.length; i++) { 27 | var currentParam = qsa[i].split('='); 28 | 29 | if (currentParam.length !== 2) { 30 | continue; 31 | } 32 | 33 | if (currentParam[0] == paramKey) { 34 | keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); 35 | } 36 | } 37 | 38 | if (keyword !== "") { 39 | $(".contents").unmark({ 40 | done: function() { 41 | $(".contents").mark(keyword); 42 | } 43 | }); 44 | } 45 | } 46 | }; 47 | 48 | mark(); 49 | }); 50 | }); 51 | 52 | /* Search term highlighting ------------------------------*/ 53 | 54 | function matchedWords(hit) { 55 | var words = []; 56 | 57 | var hierarchy = hit._highlightResult.hierarchy; 58 | // loop to fetch from lvl0, lvl1, etc. 59 | for (var idx in hierarchy) { 60 | words = words.concat(hierarchy[idx].matchedWords); 61 | } 62 | 63 | var content = hit._highlightResult.content; 64 | if (content) { 65 | words = words.concat(content.matchedWords); 66 | } 67 | 68 | // return unique words 69 | var words_uniq = [...new Set(words)]; 70 | return words_uniq; 71 | } 72 | 73 | function updateHitURL(hit) { 74 | 75 | var words = matchedWords(hit); 76 | var url = ""; 77 | 78 | if (hit.anchor) { 79 | url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; 80 | } else { 81 | url = hit.url + '?q=' + escape(words.join(" ")); 82 | } 83 | 84 | return url; 85 | } 86 | -------------------------------------------------------------------------------- /docs/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /docs/pkgdown.js: -------------------------------------------------------------------------------- 1 | /* http://gregfranko.com/blog/jquery-best-practices/ */ 2 | (function($) { 3 | $(function() { 4 | 5 | $('.navbar-fixed-top').headroom(); 6 | 7 | $('body').css('padding-top', $('.navbar').height() + 10); 8 | $(window).resize(function(){ 9 | $('body').css('padding-top', $('.navbar').height() + 10); 10 | }); 11 | 12 | $('[data-toggle="tooltip"]').tooltip(); 13 | 14 | var cur_path = paths(location.pathname); 15 | var links = $("#navbar ul li a"); 16 | var max_length = -1; 17 | var pos = -1; 18 | for (var i = 0; i < links.length; i++) { 19 | if (links[i].getAttribute("href") === "#") 20 | continue; 21 | // Ignore external links 22 | if (links[i].host !== location.host) 23 | continue; 24 | 25 | var nav_path = paths(links[i].pathname); 26 | 27 | var length = prefix_length(nav_path, cur_path); 28 | if (length > max_length) { 29 | max_length = length; 30 | pos = i; 31 | } 32 | } 33 | 34 | // Add class to parent
  • , and enclosing
  • if in dropdown 35 | if (pos >= 0) { 36 | var menu_anchor = $(links[pos]); 37 | menu_anchor.parent().addClass("active"); 38 | menu_anchor.closest("li.dropdown").addClass("active"); 39 | } 40 | }); 41 | 42 | function paths(pathname) { 43 | var pieces = pathname.split("/"); 44 | pieces.shift(); // always starts with / 45 | 46 | var end = pieces[pieces.length - 1]; 47 | if (end === "index.html" || end === "") 48 | pieces.pop(); 49 | return(pieces); 50 | } 51 | 52 | // Returns -1 if not found 53 | function prefix_length(needle, haystack) { 54 | if (needle.length > haystack.length) 55 | return(-1); 56 | 57 | // Special case for length-0 haystack, since for loop won't run 58 | if (haystack.length === 0) { 59 | return(needle.length === 0 ? 0 : -1); 60 | } 61 | 62 | for (var i = 0; i < haystack.length; i++) { 63 | if (needle[i] != haystack[i]) 64 | return(i); 65 | } 66 | 67 | return(haystack.length); 68 | } 69 | 70 | /* Clipboard --------------------------*/ 71 | 72 | function changeTooltipMessage(element, msg) { 73 | var tooltipOriginalTitle=element.getAttribute('data-original-title'); 74 | element.setAttribute('data-original-title', msg); 75 | $(element).tooltip('show'); 76 | element.setAttribute('data-original-title', tooltipOriginalTitle); 77 | } 78 | 79 | if(ClipboardJS.isSupported()) { 80 | $(document).ready(function() { 81 | var copyButton = ""; 82 | 83 | $(".examples, div.sourceCode").addClass("hasCopyButton"); 84 | 85 | // Insert copy buttons: 86 | $(copyButton).prependTo(".hasCopyButton"); 87 | 88 | // Initialize tooltips: 89 | $('.btn-copy-ex').tooltip({container: 'body'}); 90 | 91 | // Initialize clipboard: 92 | var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { 93 | text: function(trigger) { 94 | return trigger.parentNode.textContent; 95 | } 96 | }); 97 | 98 | clipboardBtnCopies.on('success', function(e) { 99 | changeTooltipMessage(e.trigger, 'Copied!'); 100 | e.clearSelection(); 101 | }); 102 | 103 | clipboardBtnCopies.on('error', function() { 104 | changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); 105 | }); 106 | }); 107 | } 108 | })(window.jQuery || window.$) 109 | -------------------------------------------------------------------------------- /docs/pkgdown.yml: -------------------------------------------------------------------------------- 1 | pandoc: 2.11.2 2 | pkgdown: 1.6.1 3 | pkgdown_sha: ~ 4 | articles: 5 | Introduction_to_asciiSetupReader: Introduction_to_asciiSetupReader.html 6 | making-an-sps-file: making-an-sps-file.html 7 | parsing-an-sps-or-sas-file: parsing-an-sps-or-sas-file.html 8 | last_built: 2021-04-26T18:54Z 9 | 10 | -------------------------------------------------------------------------------- /docs/reference/Rplot001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/docs/reference/Rplot001.png -------------------------------------------------------------------------------- /docs/reference/figures/asciiSetupReader_badge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/docs/reference/figures/asciiSetupReader_badge.png -------------------------------------------------------------------------------- /inst/extdata/example_data.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/extdata/example_data.zip -------------------------------------------------------------------------------- /inst/rstudio/addins.dcf: -------------------------------------------------------------------------------- 1 | Name: Read fixed-width ASCII files 2 | Description: Read fixed-width ASCII file using SPSS or SAS Setup file 3 | Binding: read_ascii_setup_addin 4 | Interactive: true 5 | 6 | -------------------------------------------------------------------------------- /inst/testdata/1980_leoka_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/1980_leoka_sas.zip -------------------------------------------------------------------------------- /inst/testdata/1980_leoka_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/1980_leoka_sps.zip -------------------------------------------------------------------------------- /inst/testdata/1981_SHR_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/1981_SHR_sas.zip -------------------------------------------------------------------------------- /inst/testdata/1981_SHR_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/1981_SHR_sps.zip -------------------------------------------------------------------------------- /inst/testdata/1985_UCR_offenses_known_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/1985_UCR_offenses_known_sas.zip -------------------------------------------------------------------------------- /inst/testdata/1985_UCR_offenses_known_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/1985_UCR_offenses_known_sps.zip -------------------------------------------------------------------------------- /inst/testdata/1986_UCR_offenses_known_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/1986_UCR_offenses_known_sas.zip -------------------------------------------------------------------------------- /inst/testdata/1986_UCR_offenses_known_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/1986_UCR_offenses_known_sps.zip -------------------------------------------------------------------------------- /inst/testdata/1987_SHR_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/1987_SHR_sas.zip -------------------------------------------------------------------------------- /inst/testdata/1987_SHR_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/1987_SHR_sps.zip -------------------------------------------------------------------------------- /inst/testdata/1988_SHR_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/1988_SHR_sas.zip -------------------------------------------------------------------------------- /inst/testdata/1988_SHR_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/1988_SHR_sps.zip -------------------------------------------------------------------------------- /inst/testdata/2000_UCR_offenses_known_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/2000_UCR_offenses_known_sas.zip -------------------------------------------------------------------------------- /inst/testdata/2000_UCR_offenses_known_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/2000_UCR_offenses_known_sps.zip -------------------------------------------------------------------------------- /inst/testdata/2006_UCR_offenses_known_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/2006_UCR_offenses_known_sas.zip -------------------------------------------------------------------------------- /inst/testdata/2006_UCR_offenses_known_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/2006_UCR_offenses_known_sps.zip -------------------------------------------------------------------------------- /inst/testdata/CA_SEDD_2005_AHAL.sps: -------------------------------------------------------------------------------- 1 | /******************************************************************* 2 | * CA_SEDD_2005_AHAL.SPS: 3 | * THE SPSS CODE SHOWN BELOW WILL LOAD THE ASCII 4 | * INPATIENT STAY AHAL FILE INTO SPSS 5 | *******************************************************************/ 6 | 7 | 8 | *******************************. 9 | * Define the data file *. 10 | *******************************. 11 | 12 | DATA LIST FILE = 'CA_SEDD_2005_AHAL.ASC' FIXED / 13 | AHAID 1- 7 (A) 14 | DSHOSPID 8- 20 (A) 15 | HOSPID 21- 25 16 | HOSPST 26- 27 (A) 17 | HOSPSTCO 28- 32 18 | YEAR 33- 36. 19 | 20 | 21 | *** Specify write formats ***. 22 | FORMATS 23 | HOSPID (F4.0) / 24 | HOSPSTCO (F4.0) / 25 | YEAR (F3.0) . 26 | 27 | 28 | *** Assign labels to the variables ***. 29 | VARIABLE LABELS 30 | AHAID "AHA hospital identifier with the leading 6" 31 | DSHOSPID "Data source hospital identifier" 32 | HOSPID "HCUP hospital identification number" 33 | HOSPST "Hospital state postal code" 34 | HOSPSTCO "Hospital modified FIPS state/county code" 35 | YEAR "Calendar year" . 36 | 37 | 38 | **********************************************************. 39 | * Convert missing data to system missing values *. 40 | **********************************************************. 41 | 42 | RECODE HOSPSTCO 43 | (-9999,-8888,-6666,-5555=SYSMIS). 44 | 45 | 46 | 47 | SAVE OUTFILE = 'CA_SEDD_2005_AHAL.SAV' /COMPRESSED. 48 | -------------------------------------------------------------------------------- /inst/testdata/acs_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/acs_sas.zip -------------------------------------------------------------------------------- /inst/testdata/acs_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/acs_sps.zip -------------------------------------------------------------------------------- /inst/testdata/british_crime_teen_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/british_crime_teen_sas.zip -------------------------------------------------------------------------------- /inst/testdata/british_crime_teen_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/british_crime_teen_sps.zip -------------------------------------------------------------------------------- /inst/testdata/ca_vital.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/ca_vital.zip -------------------------------------------------------------------------------- /inst/testdata/cambridge_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/cambridge_sas.zip -------------------------------------------------------------------------------- /inst/testdata/cambridge_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/cambridge_sps.zip -------------------------------------------------------------------------------- /inst/testdata/county_arrest.sas: -------------------------------------------------------------------------------- 1 | *-------------------------------------------------------------------------* 2 | | SAS DATA DEFINITION STATEMENTS FOR ICPSR 8703 | 3 | | | 4 | | UNIFORM CRIME REPORTING PROGRAM DATA [UNITED STATES: | 5 | | COUNTY LEVEL ARREST AND OFFENSES DATA, 1977-1983 | 6 | | | 7 | | PARTS 1,3,5,7,9,11,13 | 8 | | | 9 | | FILE GENERATED: 08JUL98 | 10 | | | 11 | | This SAS setup file contains the following statements: | 12 | | | 13 | | DATA: Begins a SAS data step and names an output SAS data set. | 14 | | | 15 | | INFILE: Specifies the input data file to be read with the input | 16 | | statement. Users must replace "file-specification" with a complete | 17 | | statement of the location of the data file. | 18 | | | 19 | | INPUT: Assigns the name, type, decimal specification (if any), and | 20 | | identifies variable beginning and ending column locations. | 21 | | | 22 | | LABEL: Assigns descriptive labels to variables. Variable labels and | 23 | | variable names may be identical for certain variables. | 24 | | | 25 | | MISSING VALUE RECODES: Sets user-defined numeric missing values to | 26 | | missing as interpreted by the SAS system. Missing value recodes may not | 27 | | be present for all variables in the data file. | 28 | | | 29 | | NOTE: Users should modify this SAS setup file to suit their specific | 30 | | needs. PROC FORMAT, FORMAT, and MISSING VALUE RECODES sections have | 31 | | been marked by SAS comment statements. To include these sections in a | 32 | | final SAS setup, users should remove the SAS comment statements from | 33 | | the desired section(s). | 34 | *-------------------------------------------------------------------------; 35 | *VARIABLE DESCRIPTION FOR UCR COUNTY ARREST FILES ; 36 | *(Parts 1,3,5,7,9,11,13) ; 37 | 38 | data; 39 | infile "da8703f13" lrecl=83; 40 | 41 | input 42 | v1 1-4 43 | v2 5 44 | v3 6-7 45 | v4 8-11 46 | v5 12-13 47 | v6 14-16 48 | v7 17-23 49 | v8 24-30 50 | v9 31-36 51 | v10 37-41 52 | v11 42-46 53 | v12 47-50 54 | v13 51-54 55 | v14 55-59 56 | v15 60-64 57 | v16 65-69 58 | v17 70-74 59 | v18 75-79 60 | v19 80-83; 61 | 62 | * SAS LABEL STATEMENT; 63 | 64 | LABEL 65 | V1 = "ICPSR STUDY NUMBER" 66 | V2 = "ICPSR EDITION NUMBER" 67 | V3 = "ICPSR PART NUMBER" 68 | V4 = "ICPSR SEQUENCE NUMBER" 69 | V5 = "STATE CODE" 70 | V6 = "COUNTY CODE" 71 | V7 = "POPULATION" 72 | V8 = "GRAND TOTAL" 73 | V9 = "PART 1 TOTAL" 74 | V10 = "VIOLENT CRIMES" 75 | V11 = "PROPERTY CRIMES" 76 | V12 = "MURDER" 77 | V13 = "RAPE" 78 | V14 = "ROBBERY" 79 | V15 = "ASSAULT" 80 | V16 = "BURGLARY" 81 | V17 = "LARCENY" 82 | V18 = "VEHICLE THEFT" 83 | V19 = "ARSON"; 84 | 85 | * USER-DEFINED MISSING VALUE RECODE TO SAS SYSMIS; 86 | 87 | IF V7=9999999 THEN V7=.; IF V8=9999999 THEN V8=.; 88 | IF V9=999999 THEN V9=.; IF V10=99999 THEN V10=.; 89 | IF V11=99999 THEN V11=.; IF V12=9999 THEN V12=.; 90 | IF V13=9999 THEN V13=.; IF V14=99999 THEN V14=.; 91 | IF V15=99999 THEN V15=.; IF V16=99999 THEN V16=.; 92 | IF V17=99999 THEN V17=.; IF V18=99999 THEN V18=.; 93 | IF V19=9999 THEN V19=.; 94 | -------------------------------------------------------------------------------- /inst/testdata/cps_1973_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/cps_1973_sas.zip -------------------------------------------------------------------------------- /inst/testdata/cps_1973_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/cps_1973_sps.zip -------------------------------------------------------------------------------- /inst/testdata/cps_2004_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/cps_2004_sas.zip -------------------------------------------------------------------------------- /inst/testdata/cps_2004_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/cps_2004_sps.zip -------------------------------------------------------------------------------- /inst/testdata/detroit_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/detroit_sas.zip -------------------------------------------------------------------------------- /inst/testdata/detroit_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/detroit_sps.zip -------------------------------------------------------------------------------- /inst/testdata/drug_abuse_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/drug_abuse_sas.zip -------------------------------------------------------------------------------- /inst/testdata/drug_abuse_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/drug_abuse_sps.zip -------------------------------------------------------------------------------- /inst/testdata/dutch_election_study_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/dutch_election_study_sps.zip -------------------------------------------------------------------------------- /inst/testdata/education_1985.sas: -------------------------------------------------------------------------------- 1 | /* SAS DATA DEFINITION STATEMENTS FOR ICPSR 2136 2 | COMMON CORE OF DATA: ELEMENTARY/SECONDARY EDUCATION AGENCIES, 1985-1986 3 | 1ST ICPSR VERSION 4 | AUGUST, 1999 5 | 6 | DATA: begins a SAS data step and names an output SAS data set. 7 | 8 | INFILE: identifies the input file to be read with the input statement. 9 | Users must replace the "physical-filename" with host computer specific 10 | input file specifications. 11 | 12 | INPUT: assigns the name, type, decimal specification (if any), and 13 | specifies the beginning and ending column locations for each variable 14 | in the data file. 15 | 16 | These data definition statements have been tested for compatability 17 | with SAS Release 6.11 for UNIX and/or SAS Release 6.11 for Windows. */ 18 | 19 | data; 20 | infile "physical-filename" lrecl=152 missover pad; 21 | input 22 | FIPST 001-002 23 | AGENCY 003-007 24 | STID85 $ 008-021 25 | NAME85 $ 022-051 26 | STREET85 $ 052-076 27 | CITY85 $ 077-094 28 | ZIP85 095-099 29 | ZIP485 100-103 30 | OUTST85 $ 104-105 31 | CONUM85 106-108 32 | CONAME $ 109-133 33 | OPCODE85 134-134 34 | TYPE85 135-135 35 | UNION85 136-138 36 | GSLO85 $ 139-140 37 | GSHI85 $ 141-142 38 | FISCAL85 143-143 39 | BOARD85 144-144 40 | CMSA85 145-150 41 | MSC85 151-151 42 | BOUND85 152-152 43 | ; 44 | -------------------------------------------------------------------------------- /inst/testdata/escolar.SPS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/escolar.SPS -------------------------------------------------------------------------------- /inst/testdata/escolar_2006_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/escolar_2006_sps.zip -------------------------------------------------------------------------------- /inst/testdata/guam_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/guam_sas.zip -------------------------------------------------------------------------------- /inst/testdata/guam_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/guam_sps.zip -------------------------------------------------------------------------------- /inst/testdata/india_human_development_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/india_human_development_sas.zip -------------------------------------------------------------------------------- /inst/testdata/india_human_development_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/india_human_development_sps.zip -------------------------------------------------------------------------------- /inst/testdata/indonesia.sas: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | *-------------------------------------------------------------------------* 4 | | SAS DATA DEFINITION STATEMENTS FOR ICPSR 6706 | 5 | | THE INDONESIA FAMILY LIFE SURVEY, 1993 | 6 | | | 7 | | REVISED AND RESTRUCTURED VERSION | 8 | | | 9 | | The LRECL data should be read using the data definition statements | 10 | | provided. | 11 | | | 12 | | INFILE identifies the input file to be read with the input statement. | 13 | | Users may need to modify the "INFILE= " with the approrpriate filename. | 14 | | | 15 | | INPUT assigns the name, type, decimal specification (if any), and | 16 | | specifies the beginning and ending column locations for each variable. | 17 | | | 18 | | LABEL assigns descriptive labels to all variables. Variable labels | 19 | | and variable names may be identical for some data files. | 20 | | | 21 | | FORMAT associates the formats created by the PROC FORMAT step with | 22 | | the variables named in the INPUT statement. Users should refer to the | 23 | | codebook for a complete description of formats. | 24 | | | 25 | | NOTE: Users should modify these data definition statements to suit | 26 | | their specific needs. | 27 | *-------------------------------------------------------------------------* 28 | */ 29 | 30 | 31 | * SAS DATA, INFILE, INPUT STATEMENTS; 32 | 33 | DATA; 34 | INFILE 'da6706.p9' LRECL=64; 35 | INPUT 36 | CASE 1-8 .2 37 | NCOMB 9-16 .2 38 | ITEM $ 17-18 39 | KS01 $ 19-20 40 | KS02RP 21-28 .2 41 | NCOMB1A 29-36 .2 42 | KS03RP 37-44 .2 43 | HHID93 $ 45-51 44 | HHID $ 52-60 45 | COMMID93 $ 61-64 46 | ; 47 | 48 | * SAS LABEL; 49 | 50 | LABEL 51 | CASE='IFLS HHLD NUMBER' 52 | NCOMB='TOTAL # OF ITEMS CONSUMED' 53 | ITEM='TYPES OF STAPLE FOODS LISTED' 54 | KS01='COMBINATION CODE' 55 | KS02RP='NUMERIC VALUE: TOTAL EXPENSE IN PAST WEE' 56 | NCOMB1A='TOTAL # ITEMS SELF PRODUCED' 57 | KS03RP='NUMERIC VALUE: TOTAL SELF PRODUCED/CONSU' 58 | HHID93='HHID(93) EA+HHNUM+00' 59 | HHID='HHID(=case)' 60 | COMMID93='COMMUNITY ID TO MATCH IFLS2 COMMID93' 61 | ; 62 | -------------------------------------------------------------------------------- /inst/testdata/indonesia.sps: -------------------------------------------------------------------------------- 1 | *--------------------------------------------------------------------------* 2 | | SPSS DATA DEFINITION STATEMENTS FOR ICPSR 6706 | 3 | | THE INDONESIA FAMILY LIFE SURVEY, 1993 | 4 | | | 5 | | REVISED AND RESTRUCTURED VERSION | 6 | | | 7 | | The LRECL data should be read using the data definition statements | 8 | | provided. | 9 | | | 10 | | SPSS setup sections are provided for the LRECL version of this data | 11 | | collection. These sections are listed below: | 12 | | | 13 | | DATA LIST assigns the name, type, and decimal specification (if any), | 14 | | and specifies the beginning and ending column location for each | 15 | | variable. Users may need to modify the "FILE= " in the DATA LIST | 16 | | statement with the appropriate filename. | 17 | | | 18 | | VARIABLE LABELS assigns descriptive labels to numeric variables. | 19 | | | 20 | | VALUE LABELS assigns descriptive labels to values but users | 21 | | should refer to the codebook for a complete description of values. | 22 | | | 23 | | NOTE: Users should modify these data definition statements to suit | 24 | | their specific needs. | 25 | *-------------------------------------------------------------------------*. 26 | 27 | 28 | 29 | * SPSS DATA LIST. 30 | 31 | DATA LIST FILE="da6706.p9" / 32 | CASE 1-8 (2) 33 | NCOMB 9-16 (2) 34 | ITEM 17-18 (A) 35 | KS01 19-20 (A) 36 | KS02RP 21-28 (2) 37 | NCOMB1A 29-36 (2) 38 | KS03RP 37-44 (2) 39 | HHID93 45-51 (A) 40 | HHID 52-60 (A) 41 | COMMID93 61-64 (A) 42 | . 43 | 44 | * SPSS VARIABLE LABELS. 45 | 46 | VARIABLE LABELS 47 | CASE "IFLS HHLD NUMBER" 48 | NCOMB "TOTAL # OF ITEMS CONSUMED" 49 | ITEM "TYPES OF STAPLE FOODS LISTED" 50 | KS01 "COMBINATION CODE" 51 | KS02RP "NUMERIC VALUE: TOTAL EXPENSE IN PAST WEE" 52 | NCOMB1A "TOTAL # ITEMS SELF PRODUCED" 53 | KS03RP "NUMERIC VALUE: TOTAL SELF PRODUCED/CONSU" 54 | HHID93 "HHID(93) EA+HHNUM+00" 55 | HHID "HHID(=case)" 56 | COMMID93 "COMMUNITY ID TO MATCH IFLS2 COMMID93" 57 | . 58 | -------------------------------------------------------------------------------- /inst/testdata/jail_survey_1987.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/jail_survey_1987.zip -------------------------------------------------------------------------------- /inst/testdata/missing_value_no_s_setup_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/missing_value_no_s_setup_sps.zip -------------------------------------------------------------------------------- /inst/testdata/monitoring_the_future_1979_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/monitoring_the_future_1979_sps.zip -------------------------------------------------------------------------------- /inst/testdata/monitoring_the_future_1989_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/monitoring_the_future_1989_sps.zip -------------------------------------------------------------------------------- /inst/testdata/monitoring_the_future_1990_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/monitoring_the_future_1990_sps.zip -------------------------------------------------------------------------------- /inst/testdata/monitoring_the_future_1991_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/monitoring_the_future_1991_sps.zip -------------------------------------------------------------------------------- /inst/testdata/monitoring_the_future_1992_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/monitoring_the_future_1992_sps.zip -------------------------------------------------------------------------------- /inst/testdata/monitoring_the_future_1993_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/monitoring_the_future_1993_sps.zip -------------------------------------------------------------------------------- /inst/testdata/monitoring_the_future_1999_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/monitoring_the_future_1999_sps.zip -------------------------------------------------------------------------------- /inst/testdata/monitoring_the_future_2002_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/monitoring_the_future_2002_sps.zip -------------------------------------------------------------------------------- /inst/testdata/monitoring_the_future_2003_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/monitoring_the_future_2003_sps.zip -------------------------------------------------------------------------------- /inst/testdata/monitoring_the_future_2004_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/monitoring_the_future_2004_sps.zip -------------------------------------------------------------------------------- /inst/testdata/monitoring_the_future_2012_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/monitoring_the_future_2012_sps.zip -------------------------------------------------------------------------------- /inst/testdata/mtf_2019_8_10_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/mtf_2019_8_10_sps.zip -------------------------------------------------------------------------------- /inst/testdata/ncvs_1979_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/ncvs_1979_sas.zip -------------------------------------------------------------------------------- /inst/testdata/ncvs_1979_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/ncvs_1979_sps.zip -------------------------------------------------------------------------------- /inst/testdata/nibrs_2000_batch_header1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/nibrs_2000_batch_header1.zip -------------------------------------------------------------------------------- /inst/testdata/nibrs_2000_batch_header1_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/nibrs_2000_batch_header1_sas.zip -------------------------------------------------------------------------------- /inst/testdata/nibrs_2000_batch_header1_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/nibrs_2000_batch_header1_sps.zip -------------------------------------------------------------------------------- /inst/testdata/prisoners_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/prisoners_sas.zip -------------------------------------------------------------------------------- /inst/testdata/prisoners_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/prisoners_sps.zip -------------------------------------------------------------------------------- /inst/testdata/psid_all_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/psid_all_sas.zip -------------------------------------------------------------------------------- /inst/testdata/psid_core_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/psid_core_sas.zip -------------------------------------------------------------------------------- /inst/testdata/psid_core_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/psid_core_sps.zip -------------------------------------------------------------------------------- /inst/testdata/psid_main_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/psid_main_sas.zip -------------------------------------------------------------------------------- /inst/testdata/psid_main_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/psid_main_sps.zip -------------------------------------------------------------------------------- /inst/testdata/psid_toy.sas: -------------------------------------------------------------------------------- 1 | /* PSID DATA CENTER ***************************************************** 2 | JOBID : 260564 3 | DATA_DOMAIN : FAM 4 | USER_WHERE : NULL 5 | FILE_TYPE : NULL 6 | OUTPUT_DATA_TYPE : ASCII 7 | STATEMENTS : SAS Statements 8 | CODEBOOK_TYPE : PDF 9 | N_OF_VARIABLES : 3 10 | N_OF_OBSERVATIONS: 9607 11 | MAX_REC_LENGTH : 13 12 | DATE & TIME : May 31, 2019 @ 17:40:14 13 | ************************************************************************/ 14 | 15 | FILENAME J260564 "[C:\Users\ozgu\Documents\J260564.txt" ; 16 | 17 | DATA J260564 ; 18 | ATTRIB 19 | ER66001 LABEL="RELEASE NUMBER" FORMAT=F1. 20 | ER66002 LABEL="2017 FAMILY INTERVIEW (ID) NUMBER" FORMAT=F5. 21 | ER71426 LABEL="TOTAL FAMILY INCOME-2016" FORMAT=F7. 22 | ; 23 | INFILE J260564 LRECL = 13 ; 24 | INPUT 25 | ER66001 1 - 1 ER66002 2 - 6 ER71426 7 - 13 26 | ; 27 | run ; 28 | -------------------------------------------------------------------------------- /inst/testdata/sacramento_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/sacramento_sas.zip -------------------------------------------------------------------------------- /inst/testdata/sacramento_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/sacramento_sps.zip -------------------------------------------------------------------------------- /inst/testdata/starting_number_bigger_than_ending_number.sps: -------------------------------------------------------------------------------- 1 | nibrs_window_arrestee_segment 2 | 3 | This setup file was created using the R package asciiSetupReader(version 2.3.1) on 2020-03-17 11:01:03. For any feedback or problems (or if the file looks odd), please make a report on https://github.com/jacobkap/asciiSetupReader/issues. For more information on this package see here: https://jacobkap.github.io/asciiSetupReader/. 4 | 5 | 6 | data list 7 | V1 1-2 8 | V2 30-4 9 | V3 5-13 10 | V4 14-25 11 | V5 26-33 12 | V6 66-35 13 | V7 36-47 14 | V8 48-55 15 | V9 56 16 | V10 57 17 | . 18 | 19 | variable labels 20 | V1 "segment_level" 21 | V2 "state" 22 | V3 "ori" 23 | V4 "incident_number" 24 | V5 "incident_date" 25 | V6 "arrestee_sequence_number" 26 | V7 "arrest_transaction_number" 27 | V8 "arrest_date" 28 | V9 "type_of_arrest" 29 | V10 "multiple_arrestee_indicator" 30 | . 31 | 32 | 33 | execute 34 | -------------------------------------------------------------------------------- /inst/testdata/step_in.sas: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | | 3 | | SAS SETUP FILE FOR ICPSR 30221 4 | | CRIMINAL JUSTICE DRUG ABUSE TREATMENT STUDIES (CJDATS): 5 | | STEP 'N OUT, 2002-2006 [UNITED STATES] 6 | | (DATASET 0003: ADMINISTRATIVE DATA ON ARRESTS AND 7 | | INCARCERATION) 8 | | 9 | | 10 | | SAS setup sections are provided for the ASCII version of this data 11 | | collection. These sections are listed below: 12 | | 13 | | PROC FORMAT: creates user-defined formats for the variables. Formats 14 | | replace original value codes with value code descriptions. Only 15 | | variables with user-defined formats are included in this section. 16 | | 17 | | DATA: begins a SAS data step and names an output SAS data set. 18 | | 19 | | INFILE: identifies the input file to be read with the input statement. 20 | | Users must replace the "data-filename" with a filename specifying the 21 | | directory on the user's computer system in which the downloaded and 22 | | unzipped data file is physically located (e.g., 23 | | "c:\temp\30221-0003-data.txt"). 24 | | 25 | | INPUT: assigns the name, type, decimal specification (if any), and 26 | | specifies the beginning and ending column locations for each variable 27 | | in the data file. 28 | | 29 | | LABEL: assigns descriptive labels to all variables. Variable labels 30 | | and variable names may be identical for some variables. 31 | | 32 | | MISSING VALUE RECODES: sets user-defined numeric missing values to 33 | | missing as interpreted by the SAS system. Only variables with 34 | | user-defined missing values are included in this section. 35 | | 36 | | If any variables have more than one missing value, they are assigned 37 | | to the standard missing value of a single period (.) in the statement 38 | | below. To maintain the original meaning of missing codes, users may want 39 | | to take advantage of the SAS missing values (the letters A-Z or an 40 | | underscore preceded by a period). 41 | | 42 | | An example of a standard missing value recode: 43 | | 44 | | IF (RELATION = 98 OR RELATION = 99) THEN RELATION = .; 45 | | 46 | | The same example using special missing value recodes: 47 | | 48 | | IF RELATION = 98 THEN RELATION = .A; 49 | | IF RELATION = 99 THEN RELATION = .B; 50 | | 51 | | FORMAT: associates the formats created by the PROC FORMAT step with 52 | | the variables named in the INPUT statement. 53 | | 54 | | NOTE: Users should modify this setup file to suit their specific needs. 55 | | Sections for PROC FORMAT, FORMAT, and MISSING VALUE RECODES have been 56 | | commented out (i.e., '/*'). To include these sections in the final SAS 57 | | setup, users should remove the SAS comment indicators from the desired 58 | | section(s). 59 | | 60 | |------------------------------------------------------------------------*/ 61 | 62 | * SAS PROC FORMAT; 63 | 64 | /* 65 | PROC FORMAT; 66 | VALUE nr_days 67 | -99='(-99) missing value (date of release (event = 2) is unknown or client was still incarcerated at the time of data collection)' ; 68 | VALUE $no_recf '1'='(1) arrest data not available' ; 69 | VALUE event 1='(1) arrest that leads to incarceration' 70 | 2='(2) release from jail/prison after arrest (EVENT = 1)' 71 | 3='(3) arrest that does not lead to incarceration' ; 72 | VALUE charge -99='(-99) missing value: type of charge is unknown' 73 | 1='(1) violent: use of dangerous weapon, robbery, assault, battery, homicide, attempted homicide, manslaughter, mugging, kidnap' 74 | 2='(2) property: theft, identity theft, burglary, possession stolen vehicle, unauthorized use of vehicle, credit card forgery,' 75 | 3='(3) drug: drug possession, drug distribution, public intoxication, DUI, drug use, poss. to distribute, drug paraphernalia, m' 76 | 4='(4) parole violation' 77 | 5='(5) other: failure to appear, possession of firearm, harassment, criminal driving, false police report, child endangerment,' 78 | 6='(6) sex: prostitution, pimping, rape, sexual assault, sex w/minor' ; 79 | */ 80 | 81 | 82 | * SAS DATA, INFILE, INPUT STATEMENTS; 83 | 84 | DATA; 85 | INFILE "data-filename" LRECL=39; 86 | INPUT 87 | CID 1-4 RCTR 5-6 88 | FSDATE $7-17 EVENT_DATE $18-30 NR_DAYS 31-34 89 | NO_RECORD $35 EVENT 36 CHARGE 37-39 90 | ; 91 | 92 | 93 | * SAS LABEL STATEMENT; 94 | 95 | LABEL 96 | CID = 'CID' 97 | RCTR = 'RCTR' 98 | FSDATE = 'FSDATE' 99 | EVENT_DATE= 'EVENT_DATE' 100 | NR_DAYS = 'NR_DAYS' 101 | NO_RECORD= 'NO_RECORD' 102 | EVENT = 'EVENT' 103 | CHARGE = 'CHARGE' 104 | ; 105 | 106 | 107 | * USER-DEFINED MISSING VALUES RECODE TO SAS SYSMIS; 108 | 109 | /* 110 | IF (NR_DAYS = -99) THEN NR_DAYS = .; 111 | IF (CHARGE = -99) THEN CHARGE = .; 112 | */ 113 | 114 | 115 | * SAS FORMAT STATEMENT; 116 | 117 | /* 118 | FORMAT NR_DAYS nr_days. NO_RECORD $no_recf. EVENT event. 119 | CHARGE charge. ; 120 | */ 121 | 122 | RUN ; 123 | -------------------------------------------------------------------------------- /inst/testdata/step_in.sps: -------------------------------------------------------------------------------- 1 | *-------------------------------------------------------------------------* 2 | * 3 | * SPSS SETUP FILE FOR ICPSR 30221 4 | * CRIMINAL JUSTICE DRUG ABUSE TREATMENT STUDIES (CJDATS): 5 | * STEP 'N OUT, 2002-2006 [UNITED STATES] 6 | * (DATASET 0003: ADMINISTRATIVE DATA ON ARRESTS AND 7 | * INCARCERATION) 8 | * 9 | * 10 | * SPSS setup sections are provided for the ASCII version of this data 11 | * collection. These sections are listed below: 12 | * 13 | * DATA LIST: assigns the name, type, decimal specification (if any), 14 | * and specifies the beginning and ending column locations for each 15 | * variable in the data file. Users must replace the "data-filename" 16 | * in the DATA LIST statement with a filename specifying the directory 17 | * on the user's computer system in which the downloaded and unzipped 18 | * data file is physically located (e.g., "c:\temp\30221-0003-data.txt"). 19 | * 20 | * VARIABLE LABELS: assigns descriptive labels to all variables. 21 | * Labels and variable names may be identical for some data files. 22 | * 23 | * MISSING VALUES: declares user-defined missing values. Not all 24 | * variables in this data set necessarily have user-defined missing 25 | * values. These values can be treated specially in data transformations, 26 | * statistical calculations, and case selection. 27 | * 28 | * VALUE LABELS: assigns descriptive labels to codes found in the data 29 | * file. Not all codes necessarily have assigned value labels. 30 | * 31 | * NOTE: Users should modify this setup file to suit their specific 32 | * needs. The MISSING VALUES section has been commented out (i.e., '*'). 33 | * To include the MISSING VALUES section in the final SPSS setup, remove 34 | * the comment indicators from the desired section. 35 | * 36 | * CREATING A PERMANENT SPSS DATA FILE: If users wish to create and save 37 | * an SPSS data file for further analysis using SPSS for Windows, the 38 | * necessary "SAVE OUTFILE" command is provided in the last line of 39 | * this file. To activate the command, users must delete the leading 40 | * asterisk (*) and replace "spss-filename" with a filename specifying 41 | * the location on the user's computer system to which the new data file 42 | * will be saved (e.g., SAVE OUTFILE="c:\spsswin\data\da30221-0003.sav"). 43 | * 44 | *-------------------------------------------------------------------------. 45 | 46 | * SPSS FILE HANDLE AND DATA LIST COMMANDS. 47 | 48 | FILE HANDLE DATA / NAME="data-filename" LRECL=39. 49 | DATA LIST FILE=DATA / 50 | CID 1-4 RCTR 5-6 51 | FSDATE 7-17 (A) EVENT_DATE 18-30 (A) NR_DAYS 31-34 52 | NO_RECORD 35 (A) EVENT 36 CHARGE 37-39 53 | 54 | . 55 | 56 | * SPSS VARIABLE LABELS COMMAND. 57 | 58 | VARIABLE LABELS 59 | CID 'CID' / 60 | RCTR 'RCTR' / 61 | FSDATE 'FSDATE' / 62 | EVENT_DATE 'EVENT_DATE' / 63 | NR_DAYS 'NR_DAYS' / 64 | NO_RECORD 'NO_RECORD' / 65 | EVENT 'EVENT' / 66 | CHARGE 'CHARGE' / 67 | . 68 | 69 | 70 | * SPSS VALUE LABELS COMMAND. 71 | 72 | VALUE LABELS 73 | NR_DAYS 74 | -99 'missing value (date of release (event = 2) is unknown or client was still incarcerated at the time of data collection)' 75 | / 76 | NO_RECORD '1' 'arrest data not available' / 77 | EVENT 1 'arrest that leads to incarceration' 78 | 2 'release from jail/prison after arrest (EVENT = 1)' 79 | 3 'arrest that does not lead to incarceration' / 80 | CHARGE -99 'missing value: type of charge is unknown' 81 | 1 'violent: use of dangerous weapon, robbery, assault, battery, homicide, attempted homicide, manslaughter, mugging, kidnap' 82 | 2 'property: theft, identity theft, burglary, possession stolen vehicle, unauthorized use of vehicle, credit card forgery,' 83 | 3 'drug: drug possession, drug distribution, public intoxication, DUI, drug use, poss. to distribute, drug paraphernalia, m' 84 | 4 'parole violation' 85 | 5 'other: failure to appear, possession of firearm, harassment, criminal driving, false police report, child endangerment,' 86 | 6 'sex: prostitution, pimping, rape, sexual assault, sex w/minor' 87 | / 88 | . 89 | 90 | * SPSS MISSING VALUES COMMAND. 91 | 92 | * MISSING VALUES 93 | NR_DAYS (-99) / 94 | CHARGE (-99) / 95 | . 96 | 97 | EXECUTE. 98 | 99 | * Create SPSS system file. 100 | 101 | *SAVE OUTFILE="spss-filename.sav". 102 | -------------------------------------------------------------------------------- /inst/testdata/study_of_adolescent_health.sps: -------------------------------------------------------------------------------- 1 | *-------------------------------------------------------------------------* 2 | * 3 | * SPSS SETUP FILE FOR ICPSR 21600 4 | * NATIONAL LONGITUDINAL STUDY OF ADOLESCENT TO ADULT HEALTH 5 | * (ADD HEALTH), 1994-2008 [PUBLIC USE] 6 | * (DATASET 0031: WAVE IV: PUBLIC USE WEIGHTS) 7 | * 8 | * 9 | * SPSS setup sections are provided for the ASCII version of this data 10 | * collection. These sections are listed below: 11 | * 12 | * DATA LIST: assigns the name, type, decimal specification (if any), 13 | * and specifies the beginning and ending column locations for each 14 | * variable in the data file. Users must replace the "data-filename" 15 | * in the DATA LIST statement with a filename specifying the directory 16 | * on the user's computer system in which the downloaded and unzipped 17 | * data file is physically located (e.g., "c:\temp\21600-0031-data.txt"). 18 | * 19 | * VARIABLE LABELS: assigns descriptive labels to all variables. 20 | * Labels and variable names may be identical for some data files. 21 | * 22 | * MISSING VALUES: declares user-defined missing values. Not all 23 | * variables in this data set necessarily have user-defined missing 24 | * values. These values can be treated specially in data transformations, 25 | * statistical calculations, and case selection. 26 | * 27 | * VALUE LABELS: assigns descriptive labels to codes found in the data 28 | * file. Not all codes necessarily have assigned value labels. 29 | * 30 | * VARIABLE LEVEL: assigns measurement level to each variable (scale, 31 | * nominal, or ordinal). 32 | * 33 | * NOTE: Users should modify this setup file to suit their specific 34 | * needs. The MISSING VALUES section has been commented out (i.e., '*'). 35 | * To include the MISSING VALUES section in the final SPSS setup, remove 36 | * the comment indicators from the desired section. 37 | * 38 | * CREATING A PERMANENT SPSS DATA FILE: If users wish to create and save 39 | * an SPSS data file for further analysis using SPSS for Windows, the 40 | * necessary "SAVE OUTFILE" command is provided in the last line of 41 | * this file. To activate the command, users must delete the leading 42 | * asterisk (*) and replace "spss-filename" with a filename specifying 43 | * the location on the user's computer system to which the new data file 44 | * will be saved (e.g., SAVE OUTFILE="c:\spsswin\data\da21600-0031.sav"). 45 | * 46 | *-------------------------------------------------------------------------. 47 | 48 | * SPSS FILE HANDLE AND DATA LIST COMMANDS. 49 | 50 | FILE HANDLE DATA / NAME="data-filename" LRECL=56. 51 | DATA LIST FILE=DATA / 52 | AID 1-8 (A) CLUSTER2 9-11 53 | GSWGT4 12-26 (9) GSWGT4_2 27-41 (9) GSWGT134 42-56 (9) 54 | . 55 | 56 | * SPSS VARIABLE LABELS COMMAND 57 | 58 | VARIABLE LABELS 59 | AID 'RESPONDENT IDENTIFIER' / 60 | CLUSTER2 'Sample cluster' / 61 | GSWGT4 'Post stratified untrimmed longitudinal grand sample weight' / 62 | GSWGT4_2 'Post stratified untrimmed cross-sectional grand sample weight' / 63 | GSWGT134 'Post stratified untrimmed longitudinal grand sample weight for Waves I, III, and IV' / 64 | . 65 | 66 | EXECUTE. 67 | 68 | * SPSS VARIABLE LEVEL COMMAND. 69 | 70 | VARIABLE LEVEL 71 | CLUSTER2 72 | GSWGT4 73 | GSWGT4_2 74 | GSWGT134 75 | (scale). 76 | 77 | VARIABLE LEVEL 78 | AID 79 | (nominal). 80 | 81 | * SPSS PRINT FORMAT COMMAND. 82 | 83 | PRINT FORMAT 84 | CLUSTER2 (F3) 85 | GSWGT4 (F15.9) 86 | GSWGT4_2 (F15.9) 87 | GSWGT134 (F15.9) 88 | . 89 | 90 | * Create SPSS system file. 91 | 92 | *SAVE OUTFILE="spss-filename.sav". 93 | -------------------------------------------------------------------------------- /inst/testdata/ucr1960.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/ucr1960.zip -------------------------------------------------------------------------------- /inst/testdata/ucr1960_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/ucr1960_sas.zip -------------------------------------------------------------------------------- /inst/testdata/ucr1960_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/ucr1960_sps.zip -------------------------------------------------------------------------------- /inst/testdata/ucr_property_stolen_1998_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/ucr_property_stolen_1998_sas.zip -------------------------------------------------------------------------------- /inst/testdata/ucr_property_stolen_1998_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/ucr_property_stolen_1998_sps.zip -------------------------------------------------------------------------------- /inst/testdata/weimar.txt: -------------------------------------------------------------------------------- 1 | 01001OSTPREUSSEN 1163626091299500007850003065090993001080320000119007219400000790093523000010301711080000188041920100004610045872000005000000000000000 2 | 01001WESTPREUSSEN 0953390055685700005840002633055422401274110000230000000000000000079041000014201585080000286016107500002910028189000005100000000000000 3 | 02001BERLIN 1398476113192700008090021402111052501037200000093006187600000560056053000005101775550000160040460400003640306672000027600000450000000 4 | 03001POTSDAM II 1025867087052900008490003800086672901090790000126006547800000750019872000002301803700000208036307100004190128859000014900000000000000 5 | 04001POTSDAM I 1062098089274800008410003899088884901176470000132009562100001080033358000003801862180000209031796700003580138007000015500000310000000 6 | 05001FRANKFURT AM ODER0714688061160600008560007826060378001171680000194001912800000320010746000001801352030000224031728600005250004249000000700000000000000 7 | 06001POMMERN 0962374081501900008470002183081283601947510000239008874400001090004836000000601760750000217033302700004100015403000001900000000000000 8 | 07001BRESLAU 1055620089949500008520002136089735901375950000153000000000000000187339000020901391880000155043206600004820000963000000100002080000000 9 | 08001LIEGNITZ 0652205057215300008770001124057102900776870000136000000000000000053640000009401528050000268028685500005020000042000000000000000000000 10 | 09001OPPELN 1147745067390700005870009790066411700475160000072000000000000000321334000048400457800000068021697000003270032517000004900000000000000 11 | 10001MAGDEBURG-ANHALT 0975106084413100008660001285084284600725530000086002670300000320012899000001502140260000254049176000005830024905000003000000000000000 12 | 11001MERSEBURG 0778766066926300008590001947066731600767970000115001783100000270006573000001001612720000242010905800001630294347000044100014380000002 13 | 12001THURING-STAATEN 9999999112047099999990002731111773901761870000158000000000000000055748000005002469840000221038705600003460251764000022500000000000000 14 | 13001SCHLESWIG-HOLSTEI9999999081113899999990003085080805300618190000077006295000000780008107000001002195790000272037038400004570027301000003400579130000072 15 | 14001AUR-OSNABR-OLDENB0635695053401500008400001428053258700121670000023006897400001300135017000025401307320000245014930400002800022848000004300135450000025 16 | 15001HANN-HILDES-BRAUN1417451124834400008810002619124572500323180000026010667300000860270771000021701613240000129053521500004300082566000006600568580000046 17 | 17001MUN-MIN-SCHAUM-LI1146989099520300008680003050099215300863750000087006517200000660418075000042100969610000098030381300003060021093000002100006640000001 18 | 18001ARNSBERG 1335534116568000008730003110116257001777220000153000000000000000329339000028301157650000100047979200004130059952000005100000000000000 19 | 19001HESSEN-NASSAU 1431224120891200008450002536120637601103700000091008055500000670209477000017402653610000220049460000004100045734000003800002790000000 20 | 20001KOLN-AACHEN 1220653097319900007970002525097067400310710000032003347100000340579212000059700740000000076024711400002550005806000000600000000000000 21 | 21001KOBLENZ-TRIER 0962948082510300008570004798082030500175660000022000000000000000475269000057901421030000173018536700002260000000000000000000000000000 22 | 22001DUSSELDORF-OST 1122581095107000008470002377094869301488460000157000000000000000262252000027601163910000123024404400002570177160000018700000000000000 23 | 23001DUSSELDORF-WEST 0830499070200400008450002976069902800410250000059006658400000950348294000049800493280000071018802900002690005767000000800000010000000 24 | 24001OBERBAYERN-SCHWAB1435529117077800008160003846116693200119140000010000000000000000425766000036501297980000111038236200003280043614000003701734780000149 25 | 25001NIEDERBAYERN-OBER0714616055422700007760001534055269300000000000000000000000000000274790000049700303610000055014271500002580002514000000501023130000185 26 | 26001OBER,MIT UNTERFRA1367465114386600008360003226114064001070070000094000000000000000320565000028102284670000200041525300003640069348000006100000000000000 27 | 27001PFALZ 0520430045027700008650001055044922200000000000000008834000001970124077000027600593970000132017017900003790007229000001600000000000000 28 | 28001SACHSEN I 1091304091667500008400002815091386001205830000132009725700001060016377000001801678980000184046476900005090046976000005100000000000000 29 | 29001SACHSEN II 0753677062165600008250001733061992300720890000116000000000000000003199000000501776120000286012802900002070238994000038600000000000000 30 | 30001SACHSEN III 1044592088713300008490002534088459901170740000132000000000000000003627000000401888750000214051895500005870056068000006300000000000000 31 | 31001WURTTEM-SIGMARING1500995133129300008870003647132764601825090000138000000000000000303096000022803319630000250047020400003540036371000002700035030000003 32 | 32001BADEN 1254228105798900008440004218105377100789760000075000000000000000381135000036202268360000215036682400003480000000000000000000000000000 33 | 33001HESSEN 0755957065503300008660001426065360700433590000066007334900001120110853000017001242020000190028921100004430012633000001900000000000000 34 | 34001HAMBURG-BREM-STAD1099070097604200008880003809097223300337080000035008001600000820012316000001302518130000259044717200004600083527000008600636810000065 35 | 35001MECKLENBURG,LUBEC0514968044800100008700000814044718700583360000131001983900000440000000000000001357010000304022242000004970000000000000000108910000024 36 | 36001POSEN 9999999032611099999990001522032458801105020000340005488300001690033640000010400722660000223005329700001640000000000000000000000000000 37 | -------------------------------------------------------------------------------- /inst/testdata/weimar_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/weimar_sas.zip -------------------------------------------------------------------------------- /inst/testdata/weimar_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/weimar_sps.zip -------------------------------------------------------------------------------- /inst/testdata/worry_sas.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/worry_sas.zip -------------------------------------------------------------------------------- /inst/testdata/worry_sps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/inst/testdata/worry_sps.zip -------------------------------------------------------------------------------- /man/figures/asciiSetupReader_badge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacobkap/asciiSetupReader/cdfcf88667b63f2d4426403dc527fdc9faac2955/man/figures/asciiSetupReader_badge.png -------------------------------------------------------------------------------- /man/make_sps_setup.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/make_sps_setup.R 3 | \name{make_sps_setup} 4 | \alias{make_sps_setup} 5 | \title{Create an SPSS setup file (.sps) to use for reading in fixed-width text files} 6 | \usage{ 7 | make_sps_setup( 8 | file_name, 9 | col_positions, 10 | col_names = NULL, 11 | col_labels = NULL, 12 | value_labels = NULL, 13 | missing_values = NULL 14 | ) 15 | } 16 | \arguments{ 17 | \item{file_name}{Name of the file to be saved (e.g. "setup_file1"). There is no need to put 18 | the .sps extension in the file name.} 19 | 20 | \item{col_positions}{Either a vector of strings indicating the start and end position of each column 21 | (e.g. "1-3", "4-5") or a vector of the widths of the columns (e.g. 3, 2).} 22 | 23 | \item{col_names}{A vector of names for the columns. If none are provided, will automatically 24 | create names based on column number (e.g. V1, V2, V3).} 25 | 26 | \item{col_labels}{A vector of labels for the columns. These are often longer and more descriptive 27 | than the col_names. These are the values used as column names if 28 | real_names = TRUE in reading in the data.} 29 | 30 | \item{value_labels}{A vector with the value first, then an ' = ' then the label. Each 31 | new column should have the column named followed by ' ='.} 32 | 33 | \item{missing_values}{A vector of strings with the column name followed by the values to be 34 | replaced by NA.} 35 | } 36 | \value{ 37 | Does not return any object. Saves the .sps file that is created. 38 | } 39 | \description{ 40 | make_sps_setup() is used to create the setup file used in reading in 41 | fixed-width text files. Often the setup file comes with the data file but 42 | in some cases (usually with government data) you will need to create 43 | the setup file yourself. 44 | } 45 | \examples{ 46 | \dontrun{ 47 | value_labels <- c("var1 = ", 48 | "1 = label 1", 49 | "2 = label 2", 50 | "3 = label 3", 51 | "4 = label 4", 52 | "5 = label 5", 53 | "var3 = ", 54 | "1A = alpha", 55 | "1B = bravo", 56 | "1C = cat") 57 | missing_values <- c("state name", "9", "-8", "county", "-8") 58 | make_sps_setup(file_name = "example_name", 59 | col_positions = c(1, 3, 4, 2), 60 | col_names = c("var1", "var2", "var3", "var4"), 61 | col_labels = c("state name", "county", 62 | "population", "census region code"), 63 | value_labels = value_labels, 64 | missing_values = missing_values) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /man/parse_setup.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/parse_setup.R 3 | \name{parse_setup} 4 | \alias{parse_setup} 5 | \title{Parse the setup file (.sps or .sas).} 6 | \usage{ 7 | parse_setup(setup_file) 8 | } 9 | \arguments{ 10 | \item{setup_file}{Name of the SPSS or SAS setup file - should be a .sps or .sas (.txt also accepted as are these files in zipped format)} 11 | } 12 | \value{ 13 | A list of length 3. The first object ("setup") is a data frame 14 | containing 4 columns: first the non-descriptive name of each column, 15 | The second column is the descriptive name of the column. Columns three 16 | and four and the beginning and ending number of the column (used to 17 | determine the columns location in the fixed-with data file). 18 | 19 | The second object ("value_labels") in the list is list of named vectors for the value labels. The 20 | list has a length equal to the number of columns with value labels. If there are 21 | no value labels, this will be NULL. 22 | 23 | The third object ("missing") in the list is a data.frame with two columns. The first 24 | column says the variable name and the second column says the value that is missing 25 | and will be replaced with NA. 26 | } 27 | \description{ 28 | Parse the setup file (.sps or .sas). 29 | } 30 | \examples{ 31 | \dontrun{ 32 | sas_name <- system.file("extdata", "example_setup.sas", 33 | package = "asciiSetupReader") 34 | sas_example <- parse_setup(sas_name) 35 | 36 | sps_name <- system.file("extdata", "example_setup.sps", 37 | package = "asciiSetupReader") 38 | sps_example <- parse_setup(sps_name) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /man/read_ascii_setup.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/read_ascii_setup.R 3 | \name{read_ascii_setup} 4 | \alias{read_ascii_setup} 5 | \title{Read fixed-width ASCII file using SPSS or SAS Setup file.} 6 | \usage{ 7 | read_ascii_setup( 8 | data, 9 | setup_file, 10 | use_value_labels = TRUE, 11 | use_clean_names = TRUE, 12 | select_columns = NULL, 13 | coerce_numeric = TRUE 14 | ) 15 | } 16 | \arguments{ 17 | \item{data}{Name of the ASCII (.txt or .dat) file that contains the data. 18 | This file may be zipped with a file extension of .zip.} 19 | 20 | \item{setup_file}{Name of the SPSS or SAS setup file - should be a .sps or .sas (.txt also accepted as are these files in zipped format)} 21 | 22 | \item{use_value_labels}{If TRUE, fixes value labels of the data. e.g. If a 23 | column is "sex" and has values of 0 or 1, and the setup file says 0 = male 24 | and 1 = female, it will make that change. Using this parameter for enormous files may slow down the package considerably.} 25 | 26 | \item{use_clean_names}{If TRUE fixes column names from default column name in the 27 | setup file (e.g. V1, V2) to the descriptive label for the column provided in the file (e.g. age, sex, etc.).} 28 | 29 | \item{select_columns}{Specify which columns from the dataset you want. If 30 | NULL, will return all columns. Accepts the column number (e.g. 1:5), 31 | column name (e.g. V1, V2, etc.) or column label (e.g. VICTIM_NAME, CITY, 32 | etc.).} 33 | 34 | \item{coerce_numeric}{If TRUE (default) will make columns where all values can be made numeric 35 | into numeric columns. Useful as FALSE if variables have leading zeros - such 36 | as US Census FIPS codes.} 37 | } 38 | \value{ 39 | data.frame of the data from the ASCII file 40 | } 41 | \description{ 42 | read_ascii_setup() is used when you need to 43 | read an fixed-width ASCII (text) file that comes with a setup file. 44 | The setup file provides instructions on how to create and name the columns, 45 | and fix the key-value pairs (sometimes called value labels). This is common 46 | in government data, particular data produced before 2010. 47 | } 48 | \examples{ 49 | # Text file is zipped to save space. 50 | dataset_name <- system.file("extdata", "example_data.zip", 51 | package = "asciiSetupReader") 52 | sps_name <- system.file("extdata", "example_setup.sps", 53 | package = "asciiSetupReader") 54 | 55 | \dontrun{ 56 | example <- read_ascii_setup(data = dataset_name, 57 | setup_file = sps_name) 58 | 59 | 60 | # Does not fix value labels 61 | example2 <- read_ascii_setup(data = dataset_name, 62 | setup_file = sps_name, use_value_labels = FALSE) 63 | 64 | # Keeps original column names 65 | example3 <- read_ascii_setup(data = dataset_name, 66 | setup_file = sps_name, use_clean_names = FALSE) 67 | } 68 | 69 | # Only returns the first 5 columns 70 | example4 <- read_ascii_setup(data = dataset_name, 71 | setup_file = sps_name, select_columns = 1:5) 72 | } 73 | -------------------------------------------------------------------------------- /man/read_ascii_setup_addin.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/read_ascii_setup_addin.R 3 | \name{read_ascii_setup_addin} 4 | \alias{read_ascii_setup_addin} 5 | \title{Launch an RStudio addin to select options for read_ascii_setup()} 6 | \usage{ 7 | read_ascii_setup_addin() 8 | } 9 | \value{ 10 | read_ascii_setup() code to console with options based on user input 11 | } 12 | \description{ 13 | Launch an RStudio addin to select options for read_ascii_setup(). 14 | } 15 | \examples{ 16 | \dontrun{ 17 | read_ascii_setup_addin() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /man/sas_ascii_reader.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/sas.R 3 | \name{sas_ascii_reader} 4 | \alias{sas_ascii_reader} 5 | \title{Read fixed-width ASCII file using SAS Setup file.} 6 | \usage{ 7 | sas_ascii_reader( 8 | dataset_name, 9 | sas_name, 10 | value_label_fix = TRUE, 11 | real_names = TRUE, 12 | keep_columns = NULL, 13 | coerce_numeric = TRUE 14 | ) 15 | } 16 | \arguments{ 17 | \item{dataset_name}{Name of the ASCII (.txt) file that contains the data. 18 | This file may be zipped with a file extension of .zip.} 19 | 20 | \item{sas_name}{Name of the SAS Setup file - should be a .sas or .txt file.} 21 | 22 | \item{value_label_fix}{If TRUE, fixes value labels of the data. e.g. If a 23 | column is "sex" and has values of 0 or 1, and the setup file says 0 = male 24 | and 1 = female, it will make that change. The reader is much faster is this 25 | parameter is FALSE.} 26 | 27 | \item{real_names}{If TRUE fixes column names from default column name in the 28 | SPSS setup file (e.g. V1, V2) to the name is says the column is called 29 | (e.g. age, sex, etc.).} 30 | 31 | \item{keep_columns}{Specify which columns from the dataset you want. If 32 | NULL, will return all columns. Accepts the column number (e.g. 1:5), 33 | column name (e.g. V1, V2, etc.) or column label (e.g. VICTIM_NAME, CITY, 34 | etc.).} 35 | 36 | \item{coerce_numeric}{If TRUE (default) will make columns where all values can be made numeric 37 | into numeric columns.Useful as FALSE if variables have leading zeros - such 38 | as US Census FIPS codes.} 39 | } 40 | \description{ 41 | sas_ascii_reader() and spss_ascii_reader() are used when you need to 42 | read an fixed-width ASCII (text) file that comes with a setup file. These file 43 | combinations are sometimes referred to as .txt+.sps, .txt+.sas, 44 | .dat+.sps, or .dat+.sas. 45 | The setup file provides instructions on how to create and name the columns, 46 | and fix the key-value pairs (sometimes called value labels). This is common 47 | in government data, particular data produced before 2010. 48 | } 49 | \examples{ 50 | # Text file is zipped to save space. 51 | dataset_name <- system.file("extdata", "example_data.zip", 52 | package = "asciiSetupReader") 53 | sas_name <- system.file("extdata", "example_setup.sas", 54 | package = "asciiSetupReader") 55 | 56 | \dontrun{ 57 | example <- sas_ascii_reader(dataset_name = dataset_name, 58 | sas_name = sas_name) 59 | 60 | 61 | # Does not fix value labels 62 | example2 <- sas_ascii_reader(dataset_name = dataset_name, 63 | sas_name = sas_name, value_label_fix = FALSE) 64 | 65 | # Keeps original column names 66 | example3 <- sas_ascii_reader(dataset_name = dataset_name, 67 | sas_name = sas_name, real_names = FALSE) 68 | 69 | } 70 | # Only returns the first 5 columns 71 | example <- sas_ascii_reader(dataset_name = dataset_name, 72 | sas_name = sas_name, keep_columns = 1:5) 73 | 74 | } 75 | \seealso{ 76 | \code{\link{spss_ascii_reader}} For using an SPSS setup file 77 | 78 | Other ASCII Reader functions: 79 | \code{\link{spss_ascii_reader}()} 80 | } 81 | \concept{ASCII Reader functions} 82 | -------------------------------------------------------------------------------- /man/spss_ascii_reader.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/spss.R 3 | \name{spss_ascii_reader} 4 | \alias{spss_ascii_reader} 5 | \title{Read fixed-width ASCII file using SPSS Setup file.} 6 | \usage{ 7 | spss_ascii_reader( 8 | dataset_name, 9 | sps_name, 10 | value_label_fix = TRUE, 11 | real_names = TRUE, 12 | keep_columns = NULL, 13 | coerce_numeric = TRUE 14 | ) 15 | } 16 | \arguments{ 17 | \item{dataset_name}{Name of the ASCII (.txt) file that contains the data. 18 | This file may be zipped with a file extension of .zip.} 19 | 20 | \item{sps_name}{Name of the SPSS Setup file - should be a .sps or .txt 21 | (zipped text files also work) file.} 22 | 23 | \item{value_label_fix}{If TRUE, fixes value labels of the data. e.g. If a 24 | column is "sex" and has values of 0 or 1, and the setup file says 0 = male 25 | and 1 = female, it will make that change. The reader is much faster is this 26 | parameter is FALSE.} 27 | 28 | \item{real_names}{If TRUE fixes column names from default column name in the 29 | SPSS setup file (e.g. V1, V2) to the name is says the column is called 30 | (e.g. age, sex, etc.).} 31 | 32 | \item{keep_columns}{Specify which columns from the dataset you want. If 33 | NULL, will return all columns. Accepts the column number (e.g. 1:5), 34 | column name (e.g. V1, V2, etc.) or column label (e.g. VICTIM_NAME, CITY, 35 | etc.).} 36 | 37 | \item{coerce_numeric}{If TRUE (default) will make columns where all values can be made numeric 38 | into numeric columns.Useful as FALSE if variables have leading zeros - such 39 | as US Census FIPS codes.} 40 | } 41 | \value{ 42 | Data.frame of the data from the ASCII file 43 | } 44 | \description{ 45 | spss_ascii_reader() and sas_ascii_reader() are used when you need to 46 | read an fixed-width ASCII (text) file that comes with a setup file. 47 | These file combinations are sometimes referred to as .txt+.sps, .txt+.sas, 48 | .dat+.sps, or .dat+.sas. 49 | The setup file provides instructions on how to create and name the columns, 50 | and fix the key-value pairs (sometimes called value labels). This is common 51 | in government data, particular data produced before 2010. 52 | } 53 | \examples{ 54 | # Text file is zipped to save space. 55 | dataset_name <- system.file("extdata", "example_data.zip", 56 | package = "asciiSetupReader") 57 | sps_name <- system.file("extdata", "example_setup.sps", 58 | package = "asciiSetupReader") 59 | 60 | \dontrun{ 61 | example <- spss_ascii_reader(dataset_name = dataset_name, 62 | sps_name = sps_name) 63 | 64 | 65 | # Does not fix value labels 66 | example2 <- spss_ascii_reader(dataset_name = dataset_name, 67 | sps_name = sps_name, value_label_fix = FALSE) 68 | 69 | # Keeps original column names 70 | example3 <- spss_ascii_reader(dataset_name = dataset_name, 71 | sps_name = sps_name, real_names = FALSE) 72 | 73 | } 74 | # Only returns the first 5 columns 75 | example4 <- spss_ascii_reader(dataset_name = dataset_name, 76 | sps_name = sps_name, keep_columns = 1:5) 77 | 78 | } 79 | \seealso{ 80 | \code{\link{sas_ascii_reader}} For using an SAS setup file 81 | 82 | Other ASCII Reader functions: 83 | \code{\link{sas_ascii_reader}()} 84 | } 85 | \concept{ASCII Reader functions} 86 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(asciiSetupReader) 3 | 4 | test_check("asciiSetupReader") 5 | -------------------------------------------------------------------------------- /tests/testthat/test-column-names.R: -------------------------------------------------------------------------------- 1 | context("Proper column names") 2 | 3 | 4 | 5 | test_that("Fixed (real names) columns are correct - SPSS", { 6 | 7 | expect_named(SHR_names, c("IDENTIFIER_CODE", 8 | "VICTIM_2_AGE", 9 | "VICTIM_5_AGE", 10 | "VICTIM_11_ETHNIC_ORIGIN", 11 | "OFFENDER_5_ETHNIC_ORIGIN", 12 | "OFFENDER_11_SUB_CIRCUMSTANCE")) 13 | 14 | expect_named(NIBRS_names, c("SEGMENT_LEVEL", 15 | "ORIGINATING_AGENCY_IDENTIFIER", 16 | "DATE_ORI_WAS_ADDED", 17 | "CITY_NAME", 18 | "COUNTRY_DIVISION", 19 | "FBI_FIELD_OFFICE")) 20 | 21 | expect_named(UCR_names, c("ID_CODE", 22 | "JAN_MONTH_INCLUDED_IN", 23 | "MAR_TOT_CLR_OTH_WPN_ASLT", 24 | "MAY_TOT_CLR_ATMPTD_RAPE", 25 | "SEP_UNFOUND_KNIFE_ASSL", 26 | "DEC_TOT_CLR_GUN_ROBBER")) 27 | 28 | expect_named(weimar_names[1:8], c("WAHLKREISCODE", 29 | "LAND_REGIERUNGSBEZ_CODE", 30 | "DATA_TYPE_CODE", 31 | "UNIT_OF_ANALYSIS_NAME", 32 | "X1919_RT_NR_ELIGIBLE_VTRS", 33 | "X1919_RT_NR_VOTES_CAST", 34 | "X1919_RT_VOTES_CAST", 35 | "X1919_RT_OTHER_PARTIES")) 36 | 37 | }) 38 | 39 | 40 | test_that("Not fixed column names are correct - SPSS", { 41 | 42 | expect_named(SHR2_names, c("V1", "V33", "V45", 43 | "V72", "V100", "V152")) 44 | 45 | expect_named(NIBRS2_names, c("B1001", "B1003", "B1005", 46 | "B1007", "B1010", "B1015")) 47 | 48 | expect_named(UCR2_names, c("V1", "V33", "V345", 49 | "V572", "V1000", "V1400")) 50 | 51 | expect_named(weimar2_names, c("V1", "V2", "V3", 52 | "V4", "V5", "V6", 53 | "V7", "V8", "V9", 54 | "V10", "V11", "V12", 55 | "V13", "V14", "V15", 56 | "V16", "V17", "V18", 57 | "V19", "V20", "V21", 58 | "V22", "V23")) 59 | 60 | }) 61 | 62 | # Test SAS ============================================================ 63 | test_that("Fixed (real names) columns are correct - SAS", { 64 | expect_named(SHR_sas_names, c("IDENTIFIER_CODE", 65 | "VICTIM_2_AGE", 66 | "VICTIM_5_AGE", 67 | "VICTIM_11_ETHNIC_ORIGIN", 68 | "OFFENDER_5_ETHNIC_ORIGIN", 69 | "OFFENDER_11_SUB_CIRCUMSTANCE")) 70 | 71 | expect_named(NIBRS_sas_names, c("SEGMENT_LEVEL", 72 | "ORIGINATING_AGENCY_IDENTIFIER", 73 | "DATE_ORI_WAS_ADDED", 74 | "CITY_NAME", 75 | "COUNTRY_DIVISION", 76 | "FBI_FIELD_OFFICE")) 77 | 78 | expect_named(UCR_sas_names, c("ID_CODE", 79 | "JAN_MONTH_INCLUDED_IN", 80 | "MAR_TOT_CLR_OTH_WPN_ASLT", 81 | "MAY_TOT_CLR_ATMPTD_RAPE", 82 | "SEP_UNFOUND_KNIFE_ASSL", 83 | "DEC_TOT_CLR_GUN_ROBBER")) 84 | 85 | expect_named(weimar_sas_names, c("WAHLKREISCODE", 86 | "LAND_REGIERUNGSBEZ_CODE", 87 | "DATA_TYPE_CODE", 88 | "UNIT_OF_ANALYSIS_NAME", 89 | "X1919_RT_NR_ELIGIBLE_VTRS", 90 | "X1919_RT_NR_VOTES_CAST", 91 | "X1919_RT_VOTES_CAST", 92 | "X1919_RT_OTHER_PARTIES")) 93 | 94 | 95 | }) 96 | 97 | 98 | test_that("Not fixed column names are correct - SAS", { 99 | expect_named(SHR2_sas_names, c("V1", "V33", "V45", 100 | "V72", "V100", "V152")) 101 | 102 | expect_named(NIBRS2_sas_names, c("B1001", "B1003", "B1005", 103 | "B1007", "B1010", "B1015")) 104 | 105 | expect_named(UCR2_sas_names, c("V1", "V33", "V345", 106 | "V572", "V1000", "V1400")) 107 | 108 | expect_named(weimar2_sas_names, c("V1", "V2", "V3", 109 | "V4", "V5", "V6", 110 | "V7", "V8", "V9", 111 | "V10", "V11", "V12", 112 | "V13", "V14", "V15", 113 | "V16", "V17", "V18", 114 | "V19", "V20", "V21", 115 | "V22", "V23")) 116 | 117 | }) 118 | 119 | -------------------------------------------------------------------------------- /tests/testthat/test-column-type.R: -------------------------------------------------------------------------------- 1 | context("Columns are the correct type/class") 2 | 3 | 4 | test_that("Character columns are character - SPSS", { 5 | expect_is(SHR$ORI_CODE, "character") 6 | 7 | expect_is(UCR$ORI_CODE, "character") 8 | expect_is(UCR$AGENCY_NAME, "character") 9 | expect_is(UCR$AGENCY_STATE_NAME, "character") 10 | expect_is(UCR$MAILING_ADDRESS_LINE_1, "character") 11 | expect_is(UCR$MAILING_ADDRESS_LINE_2, "character") 12 | expect_is(UCR$MAILING_ADDRESS_LINE_3, "character") 13 | 14 | expect_is(NIBRS$CITY_NAME, "character") 15 | expect_is(NIBRS$STATE_ABBREVIATION, "character") 16 | expect_is(NIBRS$ORIGINATING_AGENCY_IDENTIFIER, "character") 17 | expect_is(NIBRS$JUDICIAL_DISTRICT, "character") 18 | 19 | expect_is(weimar[, 4], "character") 20 | 21 | expect_is(SHR$NUMERIC_STATE_CODE, "character") 22 | expect_is(SHR$SITUATION, "character") 23 | expect_is(SHR$VICTIM_4_ETHNIC_ORIGIN, "character") 24 | expect_is(SHR$VICTIM_1_SEX, "character") 25 | expect_is(SHR$OFFENDER_1_WEAPON, "character") 26 | 27 | expect_is(UCR$ID_CODE, "character") 28 | expect_is(UCR$NUMERIC_STATE_CODE, "character") 29 | expect_is(UCR$GROUP_NUMBER, "character") 30 | expect_is(UCR$DIVISION, "character") 31 | expect_is(UCR$NUMBER_OF_MONTHS_REPORTED, "character") 32 | 33 | expect_is(NIBRS$SEGMENT_LEVEL, "character") 34 | expect_is(NIBRS$NUMERIC_STATE_CODE, "character") 35 | expect_is(NIBRS$CORE_CITY, "character") 36 | expect_is(NIBRS$POPULATION_GROUP, "character") 37 | }) 38 | 39 | test_that("Numeric columns are Numeric - SPSS", { 40 | expect_is(SHR$ADDITIONAL_OFFENDER_COUNT, "numeric") 41 | expect_is(SHR$ADDITIONAL_VICTIM_COUNT, "numeric") 42 | expect_is(SHR$INCIDENT_NUMBER, "numeric") 43 | expect_is(SHR$POPULATION, "numeric") 44 | 45 | expect_is(UCR$POPULATION_1, "numeric") 46 | expect_is(UCR$POPULATION_3, "numeric") 47 | expect_is(UCR$JAN_CLR_under_18_ALL_FIELDS, "numeric") 48 | expect_is(UCR$JAN_ACT_VHC_THEFT_TO, "numeric") 49 | expect_is(UCR$JAN_ACT_AUTO_THEFT, "numeric") 50 | 51 | expect_is(NIBRS$N_RECORDS_PER_ORI_INCIDENT_NUMBER, "numeric") 52 | expect_is(NIBRS$DATE_ORI_WAS_ADDED, "numeric") 53 | expect_is(NIBRS$DATE_ORI_WENT_NIBRS, "numeric") 54 | 55 | expect_is(weimar[, 1], "numeric") 56 | expect_is(weimar[, 2], "numeric") 57 | expect_is(weimar[, 3], "numeric") 58 | expect_is(weimar[, 5], "numeric") 59 | expect_is(weimar[, 6], "numeric") 60 | expect_is(weimar[, 7], "numeric") 61 | expect_is(weimar[, 8], "numeric") 62 | expect_is(weimar[, 9], "numeric") 63 | expect_is(weimar[, 10], "numeric") 64 | expect_is(weimar[, 11], "numeric") 65 | }) 66 | 67 | 68 | 69 | test_that("Character columns are character - SAS", { 70 | 71 | expect_is(SHR_sas$NUMERIC_STATE_CODE, "character") 72 | expect_is(SHR_sas$SITUATION, "character") 73 | expect_is(SHR_sas$VICTIM_4_ETHNIC_ORIGIN, "character") 74 | expect_is(SHR_sas$VICTIM_1_SEX, "character") 75 | expect_is(SHR_sas$OFFENDER_1_WEAPON, "character") 76 | 77 | expect_is(UCR_sas$ID_CODE, "character") 78 | expect_is(UCR_sas$NUMERIC_STATE_CODE, "character") 79 | expect_is(UCR_sas$GROUP_NUMBER, "character") 80 | expect_is(UCR_sas$DIVISION, "character") 81 | expect_is(UCR_sas$NUMBER_OF_MONTHS_REPORTED, "character") 82 | 83 | expect_is(NIBRS_sas$SEGMENT_LEVEL, "character") 84 | expect_is(NIBRS_sas$NUMERIC_STATE_CODE, "character") 85 | expect_is(NIBRS_sas$CORE_CITY, "character") 86 | expect_is(NIBRS_sas$POPULATION_GROUP, "character") 87 | 88 | expect_is(SHR_sas$ORI_CODE, "character") 89 | 90 | expect_is(UCR_sas$ORI_CODE, "character") 91 | expect_is(UCR_sas$AGENCY_NAME, "character") 92 | expect_is(UCR_sas$AGENCY_STATE_NAME, "character") 93 | expect_is(UCR_sas$MAILING_ADDRESS_LINE_1, "character") 94 | expect_is(UCR_sas$MAILING_ADDRESS_LINE_2, "character") 95 | expect_is(UCR_sas$MAILING_ADDRESS_LINE_3, "character") 96 | 97 | expect_is(NIBRS_sas$CITY_NAME, "character") 98 | expect_is(NIBRS_sas$STATE_ABBREVIATION, "character") 99 | expect_is(NIBRS_sas$ORIGINATING_AGENCY_IDENTIFIER, "character") 100 | expect_is(NIBRS_sas$JUDICIAL_DISTRICT, "character") 101 | expect_is(weimar_sas[, 4], "character") 102 | }) 103 | 104 | test_that("Numeric columns are Numeric - SAS", { 105 | expect_is(SHR_sas$ADDITIONAL_OFFENDER_COUNT, "numeric") 106 | expect_is(SHR_sas$ADDITIONAL_VICTIM_COUNT, "numeric") 107 | expect_is(SHR_sas$INCIDENT_NUMBER, "numeric") 108 | expect_is(SHR_sas$POPULATION, "numeric") 109 | 110 | expect_is(UCR_sas$POPULATION_1, "numeric") 111 | expect_is(UCR_sas$POPULATION_3, "numeric") 112 | expect_is(UCR_sas$JAN_CLR_under_18_ALL_FIELDS, "numeric") 113 | expect_is(UCR_sas$JAN_ACT_VHC_THEFT_TO, "numeric") 114 | expect_is(UCR_sas$JAN_ACT_AUTO_THEFT, "numeric") 115 | 116 | expect_is(NIBRS_sas$N_RECORDS_PER_ORI_INCIDENT_NUMBER, "numeric") 117 | expect_is(NIBRS_sas$DATE_ORI_WAS_ADDED, "numeric") 118 | expect_is(NIBRS_sas$DATE_ORI_WENT_NIBRS, "numeric") 119 | 120 | expect_is(weimar_sas[, 1], "numeric") 121 | expect_is(weimar_sas[, 2], "numeric") 122 | expect_is(weimar_sas[, 3], "numeric") 123 | expect_is(weimar_sas[, 5], "numeric") 124 | expect_is(weimar_sas[, 6], "numeric") 125 | expect_is(weimar_sas[, 7], "numeric") 126 | expect_is(weimar_sas[, 8], "numeric") 127 | expect_is(weimar_sas[, 9], "numeric") 128 | expect_is(weimar_sas[, 10], "numeric") 129 | expect_is(weimar_sas[, 11], "numeric") 130 | }) 131 | 132 | 133 | -------------------------------------------------------------------------------- /tests/testthat/test-dimensions-missing.R: -------------------------------------------------------------------------------- 1 | context("Proper dimensions and missing values") 2 | 3 | test_that("number of columns is correct - SPSS", { 4 | 5 | expect_equal(ncol(SHR2), 5) 6 | expect_equal(ncol(SHR3), 31) 7 | expect_equal(ncol(UCR2), 5) 8 | expect_equal(ncol(NIBRS2), 5) 9 | expect_equal(ncol(SHR), 152) 10 | expect_equal(ncol(UCR), 150) 11 | expect_equal(ncol(NIBRS), 20) 12 | 13 | }) 14 | 15 | 16 | test_that("number of rows is correct - SPSS", { 17 | expect_equal(nrow(SHR2), 13844) 18 | expect_equal(nrow(SHR3), 13844) 19 | expect_equal(nrow(UCR2), 8452) 20 | expect_equal(nrow(NIBRS2), 19711) 21 | 22 | expect_equal(nrow(SHR), 13844) 23 | expect_equal(nrow(UCR), 8452) 24 | expect_equal(nrow(NIBRS), 19711) 25 | }) 26 | 27 | 28 | # Check for appropriate number of NAs 29 | test_that("Character columns have proper number of NAs - SPSS", { 30 | expect_equal(sum(is.na(SHR$ORI_CODE)), 0) 31 | expect_equal(sum(is.na(SHR$LAST_UPDATE)), 0) 32 | 33 | expect_equal(sum(is.na(UCR$JAN_CARD_0_P_T)), 8452) 34 | expect_equal(sum(is.na(UCR$MAILING_ADDRESS_LINE_1)), 200) 35 | expect_equal(sum(is.na(UCR$MAILING_ADDRESS_LINE_2)), 2) 36 | expect_equal(sum(is.na(UCR$MAILING_ADDRESS_LINE_4)), 8452) 37 | 38 | 39 | expect_equal(sum(is.na(NIBRS$ORIGINATING_AGENCY_IDENTIFIER)), 0) 40 | expect_equal(sum(is.na(NIBRS$CITY_NAME)), 0) 41 | expect_equal(sum(is.na(NIBRS$COVERED_BY_ORI)), 16900) 42 | }) 43 | 44 | test_that("Numeric columns have proper number of NAs - SPSS", { 45 | expect_equal(sum(is.na(SHR$ADDITIONAL_VICTIM_COUNT)), 0) 46 | expect_equal(sum(is.na(SHR$ADDITIONAL_OFFENDER_COUNT)), 0) 47 | expect_equal(sum(is.na(SHR$POPULATION)), 0) 48 | 49 | expect_equal(sum(is.na(UCR$ZIP_CODE)), 0) 50 | expect_equal(sum(is.na(UCR$JAN_ACT_NUM_MURDER)), 0) 51 | expect_equal(sum(is.na(UCR$JAN_ACT_NUM_MANSLGHTR)), 0) 52 | expect_equal(sum(is.na(UCR$JAN_ACT_NUM_ROBBRY_TOTL)), 0) 53 | 54 | expect_equal(sum(is.na(NIBRS$N_RECORDS_PER_ORI_INCIDENT_NUMBER)), 0) 55 | expect_equal(sum(is.na(NIBRS$FILLER_BLANKS)), 19711) 56 | expect_equal(sum(is.na(NIBRS$COUNTRY_DIVISION)), 0) 57 | }) 58 | 59 | test_that("Factor columns have proper number of NAs - SPSS", { 60 | expect_equal(sum(is.na(SHR$VICTIM_1_RACE)), 0) 61 | expect_equal(sum(is.na(SHR$VICTIM_10_RACE)), 13843) 62 | expect_equal(sum(is.na(SHR$OFFENDER_1_RACE)), 0) 63 | expect_equal(sum(is.na(SHR$OFFENDER_10_RACE)), 13842) 64 | 65 | expect_equal(sum(is.na(SHR$VICTIM_1_AGE)), 0) 66 | expect_equal(sum(is.na(SHR$VICTIM_4_AGE)), 13807) 67 | expect_equal(sum(is.na(SHR$OFFENDER_1_AGE)), 0) 68 | expect_equal(sum(is.na(SHR$OFFENDER_4_AGE)), 13530) 69 | 70 | expect_equal(sum(is.na(UCR$ID_CODE)), 0) 71 | expect_equal(sum(is.na(UCR$NUMERIC_STATE_CODE)), 0) 72 | expect_equal(sum(is.na(UCR$FOLLOW_UP_INDICATION)), 0) 73 | expect_equal(sum(is.na(UCR$JAN_MONTH_INCLUDED_IN)), 7343) 74 | 75 | expect_equal(sum(is.na(NIBRS$POPULATION_GROUP)), 1) 76 | expect_equal(sum(is.na(NIBRS$COUNTRY_DIVISION)), 0) 77 | expect_equal(sum(is.na(NIBRS$SEGMENT_LEVEL)), 0) 78 | expect_equal(sum(is.na(NIBRS$NUMERIC_STATE_CODE)), 0) 79 | 80 | }) 81 | 82 | # SAS tests 83 | test_that("number of columns is correct - SAS", { 84 | expect_equal(ncol(SHR2_sas), 5) 85 | expect_equal(ncol(SHR3_sas), 31) 86 | expect_equal(ncol(UCR2_sas), 5) 87 | expect_equal(ncol(NIBRS2_sas), 5) 88 | 89 | expect_equal(ncol(SHR_sas), 152) 90 | expect_equal(ncol(UCR_sas), 150) 91 | expect_equal(ncol(NIBRS_sas), 20) 92 | 93 | }) 94 | 95 | 96 | test_that("number of rows is correct - SAS", { 97 | expect_equal(nrow(SHR2_sas), 13844) 98 | expect_equal(nrow(SHR3_sas), 13844) 99 | expect_equal(nrow(UCR2_sas), 8452) 100 | expect_equal(nrow(NIBRS2_sas), 19711) 101 | expect_equal(nrow(SHR_sas), 13844) 102 | expect_equal(nrow(UCR_sas), 8452) 103 | expect_equal(nrow(NIBRS_sas), 19711) 104 | 105 | }) 106 | 107 | 108 | # Check for appropriate number of NAs 109 | test_that("Character columns have proper number of NAs - SAS", { 110 | expect_equal(sum(is.na(SHR_sas$LAST_UPDATE)), 0) 111 | 112 | expect_equal(sum(is.na(UCR_sas$JAN_CARD_0_P_T)), 8452) 113 | expect_equal(sum(is.na(UCR_sas$MAILING_ADDRESS_LINE_1)), 200) 114 | expect_equal(sum(is.na(UCR_sas$MAILING_ADDRESS_LINE_2)), 2) 115 | expect_equal(sum(is.na(UCR_sas$MAILING_ADDRESS_LINE_4)), 8452) 116 | 117 | 118 | expect_equal(sum(is.na(NIBRS_sas$ORIGINATING_AGENCY_IDENTIFIER)), 0) 119 | expect_equal(sum(is.na(NIBRS_sas$CITY_NAME)), 0) 120 | expect_equal(sum(is.na(NIBRS_sas$COVERED_BY_ORI)), 16900) 121 | }) 122 | 123 | test_that("Numeric columns have proper number of NAs - SAS", { 124 | expect_equal(sum(is.na(SHR_sas$ADDITIONAL_VICTIM_COUNT)), 0) 125 | expect_equal(sum(is.na(SHR_sas$ADDITIONAL_OFFENDER_COUNT)), 0) 126 | expect_equal(sum(is.na(SHR_sas$POPULATION)), 0) 127 | 128 | expect_equal(sum(is.na(UCR_sas$ZIP_CODE)), 0) 129 | expect_equal(sum(is.na(UCR_sas$JAN_ACT_NUM_MURDER)), 0) 130 | expect_equal(sum(is.na(UCR_sas$JAN_ACT_NUM_MANSLGHTR)), 0) 131 | expect_equal(sum(is.na(UCR_sas$JAN_ACT_NUM_ROBBRY_TOTL)), 0) 132 | 133 | expect_equal(sum(is.na(NIBRS_sas$N_RECORDS_PER_ORI_INCIDENT_NUMBER)), 0) 134 | expect_equal(sum(is.na(NIBRS_sas$FILLER_BLANKS)), 19711) 135 | expect_equal(sum(is.na(NIBRS_sas$COUNTRY_DIVISION)), 0) 136 | }) 137 | 138 | test_that("Factor columns have proper number of NAs - SAS", { 139 | expect_equal(sum(is.na(SHR_sas$VICTIM_1_RACE)), 0) 140 | expect_equal(sum(is.na(SHR_sas$VICTIM_10_RACE)), 13843) 141 | expect_equal(sum(is.na(SHR_sas$OFFENDER_1_RACE)), 0) 142 | expect_equal(sum(is.na(SHR_sas$OFFENDER_10_RACE)), 13842) 143 | 144 | expect_equal(sum(is.na(SHR_sas$VICTIM_1_AGE)), 0) 145 | expect_equal(sum(is.na(SHR_sas$VICTIM_4_AGE)), 13807) 146 | expect_equal(sum(is.na(SHR_sas$OFFENDER_1_AGE)), 0) 147 | expect_equal(sum(is.na(SHR_sas$OFFENDER_4_AGE)), 13530) 148 | 149 | expect_equal(sum(is.na(UCR_sas$ID_CODE)), 0) 150 | expect_equal(sum(is.na(UCR_sas$NUMERIC_STATE_CODE)), 0) 151 | expect_equal(sum(is.na(UCR_sas$FOLLOW_UP_INDICATION)), 0) 152 | expect_equal(sum(is.na(UCR_sas$JAN_MONTH_INCLUDED_IN)), 7343) 153 | 154 | expect_equal(sum(is.na(NIBRS_sas$POPULATION_GROUP)), 1) 155 | expect_equal(sum(is.na(NIBRS_sas$COUNTRY_DIVISION)), 0) 156 | expect_equal(sum(is.na(NIBRS_sas$SEGMENT_LEVEL)), 0) 157 | expect_equal(sum(is.na(NIBRS_sas$NUMERIC_STATE_CODE)), 0) 158 | 159 | }) 160 | -------------------------------------------------------------------------------- /tests/testthat/test-error.R: -------------------------------------------------------------------------------- 1 | test_that("error handling works", { 2 | expect_error(parse_setup(starting_number_bigger_than_ending_number)) 3 | }) 4 | -------------------------------------------------------------------------------- /tests/testthat/test-missing-values.R: -------------------------------------------------------------------------------- 1 | context("Make sure missing values are removed") 2 | 3 | test_that("number of missing values is correct - SPSS", { 4 | expect_equal(sum(is.na(weimar$X1919_RT_NR_ELIGIBLE_VTRS)), 3) 5 | 6 | expect_equal(sum(is.na(parole$TOTBEG)), 0) 7 | expect_equal(sum(parole$ENDISREL %in% "Not known/Dont know"), 4) 8 | expect_equal(sum(parole$ENMANREL %in% "Not applicable"), 5) 9 | expect_equal(sum(parole$ENMANREL %in% "Not known/Dont know"), 6) 10 | expect_equal(sum(parole$ENREINST %in% "Not applicable"), 6) 11 | expect_equal(sum(parole$ENREINST %in% "Not known/Dont know"), 12) 12 | expect_equal(sum(parole$OTHEN %in% "Not applicable"), 4) 13 | expect_equal(sum(parole$OTHEN %in% "Not known/Dont know"), 4) 14 | expect_equal(sum(parole$TOTEN %in% "Not known/Dont know"), 1) 15 | expect_equal(sum(parole$EXCOM %in% "Not known/Dont know"), 2) 16 | expect_equal(sum(parole$EXINCNEW %in% "Not applicable"), 1) 17 | expect_equal(sum(parole$EXINCNEW %in% "Not known/Dont know"), 10) 18 | expect_equal(sum(parole$EXINCREV %in% "Not known/Dont know"), 3) 19 | expect_equal(sum(parole$EXINCOTH %in% "Not applicable"), 7) 20 | expect_equal(sum(parole$EXINCOTH %in% "Not known/Dont know"), 7) 21 | expect_equal(sum(parole$EXTRANS %in% "Not known/Dont know"), 10) 22 | expect_equal(sum(parole$EXTRANS %in% "Not applicable"), 3) 23 | expect_equal(sum(parole$EXDTH %in% "Not applicable"), 1) 24 | expect_equal(sum(parole$EXDTH %in% "Not known/Dont know"), 3) 25 | expect_equal(sum(parole$EXOTH %in% "Not applicable"), 2) 26 | expect_equal(sum(parole$EXOTH %in% "Not known/Dont know"), 3) 27 | expect_equal(sum(parole$TOTEX %in% "Not known/Dont know"), 1) 28 | expect_equal(sum(is.na(parole$TOTEND)), 0) 29 | expect_equal(sum(parole$MALE %in% "Not known/Dont know"), 2) 30 | expect_equal(sum(parole$FEML %in% "Not known/Dont know"), 2) 31 | expect_equal(sum(is.na(parole$TOTGEND)), 0) 32 | expect_equal(sum(parole$WHITE %in% "Not known/Dont know"), 5) 33 | expect_equal(sum(parole$BLACK %in% "Not known/Dont know"), 5) 34 | expect_equal(sum(parole$AMINALK %in% "Not known/Dont know"), 10) 35 | expect_equal(sum(parole$ASHAWPAC %in% "Not known/Dont know"), 11) 36 | expect_equal(sum(parole$ADDRACE %in% "Not known/Dont know"), 7) 37 | expect_equal(sum(is.na(parole$TOTRACE)), 0) 38 | expect_equal(sum(parole$HISP %in% "Not known/Dont know"), 17) 39 | expect_equal(sum(parole$NONHISP %in% "Not known/Dont know"), 17) 40 | expect_equal(sum(is.na(parole$TOTHISP)), 0) 41 | expect_equal(sum(parole$MAXYEAR %in% "Not applicable"), 6) 42 | expect_equal(sum(parole$MAXYEAR %in% "Not known/Dont know"), 9) 43 | expect_equal(sum(parole$MAXMORE %in% "Not applicable"), 1) 44 | expect_equal(sum(parole$MAXMORE %in% "Not known/Dont know"), 9) 45 | expect_equal(sum(is.na(parole$TOTMAX)), 0) 46 | expect_equal(sum(parole$ACTIVE %in% "Not known/Dont know"), 1) 47 | expect_equal(sum(parole$INACTIVE %in% "Not applicable"), 5) 48 | expect_equal(sum(parole$INACTIVE %in% "Not known/Dont know"), 5) 49 | expect_equal(sum(parole$ABSND %in% "Not applicable"), 1) 50 | expect_equal(sum(parole$ABSND %in% "Not known/Dont know"), 5) 51 | expect_equal(sum(parole$OUTSTATE %in% "Not known/Dont know"), 3) 52 | expect_equal(sum(parole$OTHSTAT %in% "Not applicable"), 2) 53 | expect_equal(sum(parole$OTHSTAT %in% "Not known/Dont know"), 1) 54 | expect_equal(sum(is.na(parole$TOTSTAT)), 0) 55 | 56 | expect_equal(sum(parole$ISPNUM %in% "Not applicable"), 12) 57 | expect_equal(sum(parole$ISPNUM %in% "Not known/Dont know"), 4) 58 | expect_equal(sum(parole$ISPIN %in% "Not known/Dont know"), 3) 59 | expect_equal(sum(parole$EMNUM %in% "Not applicable"), 21) 60 | expect_equal(sum(parole$EMNUM %in% "Not known/Dont know"), 4) 61 | expect_equal(sum(parole$EMIN %in% "Not known/Dont know"), 4) 62 | expect_equal(sum(parole$BOOTNUM %in% "Not applicable"), 48) 63 | expect_equal(sum(parole$BOOTNUM %in% "Not known/Dont know"), 1) 64 | expect_equal(sum(parole$BOOTIN %in% "Not known/Dont know"), 1) 65 | expect_equal(sum(parole$LOCJAIL %in% "Not known/Dont know"), 3) 66 | expect_equal(sum(parole$LOCJAILIN %in% "Not known/Dont know"), 13) 67 | expect_equal(sum(parole$OTHPAR %in% "Not known/Dont know"), 2) 68 | expect_equal(sum(parole$ENDOFYEAR %in% "Not known/Dont know"), 2) 69 | 70 | 71 | }) 72 | 73 | 74 | -------------------------------------------------------------------------------- /vignettes/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.R 3 | -------------------------------------------------------------------------------- /vignettes/Introduction_to_asciiSetupReader.R: -------------------------------------------------------------------------------- 1 | ## ----------------------------------------------------------------------------- 2 | data <- system.file("extdata", "example_data.zip", 3 | package = "asciiSetupReader") 4 | setup_file <- system.file("extdata", "example_setup.sps", 5 | package = "asciiSetupReader") 6 | 7 | example <- asciiSetupReader::read_ascii_setup(data = data, 8 | setup_file = setup_file) 9 | example[1:6, 1:4] # Look at first 6 rows and first 4 columns 10 | 11 | ## ----------------------------------------------------------------------------- 12 | example <- asciiSetupReader::read_ascii_setup(data = data, 13 | setup_file = setup_file, 14 | use_value_labels = FALSE) 15 | example[1:6, 1:4] # Look at first 6 rows and first 4 columns 16 | 17 | ## ----------------------------------------------------------------------------- 18 | example <- asciiSetupReader::read_ascii_setup(data = data, 19 | setup_file = setup_file, 20 | use_clean_names = FALSE) 21 | example[1:6, 1:4] # Look at first 6 rows and first 4 columns 22 | 23 | ## ----------------------------------------------------------------------------- 24 | example <- asciiSetupReader::read_ascii_setup(data = data, 25 | setup_file = setup_file, 26 | select_columns = 1:2) # Gets only the first 2 columns 27 | head(example) 28 | 29 | ## ----------------------------------------------------------------------------- 30 | example <- asciiSetupReader::read_ascii_setup(data = data, 31 | setup_file = setup_file, 32 | select_columns = c("IDENTIFIER_CODE", "NUMERIC_STATE_CODE")) # Gets only the first 2 columns 33 | head(example) 34 | 35 | ## ----------------------------------------------------------------------------- 36 | example <- asciiSetupReader::read_ascii_setup(data = data, 37 | setup_file = setup_file, 38 | select_columns = "V1") # Gets only the first columnss 39 | head(example) 40 | 41 | -------------------------------------------------------------------------------- /vignettes/Introduction_to_asciiSetupReader.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Introduction to asciiSetupReader" 3 | author: "Jacob Kaplan" 4 | date: "`r Sys.Date()`" 5 | output: rmarkdown::html_vignette 6 | vignette: > 7 | %\VignetteIndexEntry{Introduction to asciiSetupReader} 8 | %\VignetteEngine{knitr::rmarkdown} 9 | %\VignetteEncoding{UTF-8} 10 | --- 11 | 12 | Some (usually older) data sets are only available in fixed-width ASCII files (.txt or .dat) that have an .sps (SPSS) or .sas (SAS) setup file explaining to the software how to read that file. This package allows you to read in the data if you have both the fixed-width file and its accompanying setup file. These parameters `data` and `setup_file` are the only ones requires to run the package though three optional parameters allow you to customize results. 13 | 14 | `data` - A string containing the name of the data file 15 | 16 | `setup_file` - A string containing the name of the data file 17 | 18 | Both files must be in your working directory or the string must contain the path to the file. Below is an example of reading in the example dataset - the original data and setup files can be found [here](https://www.icpsr.umich.edu/icpsrweb/NACJD/studies/9327?q=&restrictionType%5B0%5D=Public+Use&classification%5B0%5D=NACJD.IX.*&dataFormat%5B0%5D=SPSS). 19 | 20 | Please note that I am only using `system.file()` here so the vignette builds in the package even not on my own computer. You will not use this in the function. Instead you'd simply input `data = "example_data.zip"` and `setup_file = "example_setup.sps"`. The data file does not have to be in a zip folder, it is only in a zip folder here to reduce the size of this package. In most cases it will be a .dat or a .txt file. 21 | 22 | ```{r} 23 | data <- system.file("extdata", "example_data.zip", 24 | package = "asciiSetupReader") 25 | setup_file <- system.file("extdata", "example_setup.sps", 26 | package = "asciiSetupReader") 27 | 28 | example <- asciiSetupReader::read_ascii_setup(data = data, 29 | setup_file = setup_file) 30 | example[1:6, 1:4] # Look at first 6 rows and first 4 columns 31 | ``` 32 | There are three optional parameters: `use_value_labels`, `use_clean_names`, and `select_columns`. 33 | 34 | ## `use_value_labels` 35 | Fixed-width delimited text files are designed to be as compressed as possible. One way of doing this is having letters or numbers represent values. For example, instead of writing "male" or "female" in a column about gender, it will be "0" or "1" (or "M" and "F"). The setup file gives the actual value of these representations. When the parameter `use_value_labels` is TRUE (which it is by default) it will give the value labels; otherwise it will give only the representation. This parameter is the most time consuming part of the function so if you have a very large dataset but only a few variables you are interested in, it may be wise to set it as FALSE (or use the parameter `select_columns` to get only those columns). 36 | 37 | ```{r} 38 | example <- asciiSetupReader::read_ascii_setup(data = data, 39 | setup_file = setup_file, 40 | use_value_labels = FALSE) 41 | example[1:6, 1:4] # Look at first 6 rows and first 4 columns 42 | ``` 43 | 44 | ## `use_clean_names` 45 | Column names are similar to how there are both value representations and value labels for values in a column. The columns may have a non-descriptive name (e.g. V1, V2) or a descriptive one (e.g. CITY, GENDER). When `use_clean_names` is TRUE (which it is by), the descriptive name is given; otherwise the non-descriptive name is given. 46 | ```{r} 47 | example <- asciiSetupReader::read_ascii_setup(data = data, 48 | setup_file = setup_file, 49 | use_clean_names = FALSE) 50 | example[1:6, 1:4] # Look at first 6 rows and first 4 columns 51 | ``` 52 | 53 | ## `select_columns` 54 | This parameter allows you to return only the specific columns you want. It is very useful when dealing with a large file which you only want part of. It accepts 3 inputs: column numbers, the non-descriptive column names, or the descriptive column names - you can only choose one input type, cannot mix them together. To get the column names and numbers, consult with the g documentation. 55 | 56 | This gets only the first two columns of data and specifies the columns by number. 57 | ```{r} 58 | example <- asciiSetupReader::read_ascii_setup(data = data, 59 | setup_file = setup_file, 60 | select_columns = 1:2) # Gets only the first 2 columns 61 | head(example) 62 | ``` 63 | 64 | This gets only the first two columns of data and specifies the columns by descriptive names. 65 | ```{r} 66 | example <- asciiSetupReader::read_ascii_setup(data = data, 67 | setup_file = setup_file, 68 | select_columns = c("IDENTIFIER_CODE", "NUMERIC_STATE_CODE")) # Gets only the first 2 columns 69 | head(example) 70 | ``` 71 | 72 | 73 | This gets only the first column of data and specifies the column by non-descriptive names. 74 | ```{r} 75 | example <- asciiSetupReader::read_ascii_setup(data = data, 76 | setup_file = setup_file, 77 | select_columns = "V1") # Gets only the first columnss 78 | head(example) 79 | ``` 80 | -------------------------------------------------------------------------------- /vignettes/making-an-sps-file.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Making an .sps file" 3 | author: "Jacob Kaplan" 4 | date: "`r Sys.Date()`" 5 | output: rmarkdown::html_vignette 6 | vignette: > 7 | %\VignetteIndexEntry{Making an .sps file} 8 | %\VignetteEngine{knitr::rmarkdown} 9 | %\VignetteEncoding{UTF-8} 10 | --- 11 | 12 | Most times you will deal with a .dat+.sps file pair, you will be given 13 | the .sps file already made. However, in rare cases - such as working with 14 | FBI data - you need to make you own based on a PDF guide provided. 15 | 16 | The function `make_sps_setup` makes that a bit easier by doing all the 17 | formatting needed, meaning you just need to provide the info for each 18 | section. It will create a .sps setup file and save it in your working directory. 19 | 20 | There are two parameters absolutely needed - `file_name` and `col_positions` - as 21 | well as four optional parameters. 22 | 23 | * `file_name` - Name of the file to be saved (e.g. "setup_file1"). There is no need to put the .sps extension in the file name. 24 | * `col_positions` - Either a vector of strings indicating the start and end position of each column (e.g. "1-3", "4-5") or a vector of the widths of the columns (e.g. 3, 2). 25 | * `col_names` - A vector of names for the columns. If none are provided, will automatically create names based on column number (e.g. V1, V2, V3). 26 | * `col_labels` - A vector of labels for the columns. These are often longer and more descriptive than the col_names. These are the values used as column names if real_names = TRUE in reading in the data. 27 | * `value_labels` - A vector with the value first, then an ' = ' then the label. Each 28 | new column should have the column named followed by ' ='. 29 | * `missing_values` - A vector of strings with the column name followed by the values to be 30 | replaced by NA. 31 | 32 | 33 | ## file_name 34 | `file_name` is simply the string of the name you want the file to be saved as, such as "setup_file_example". Including the ".sps" to the end is not required. 35 | 36 | ## col_positions 37 | 38 | This is a vector either of strings indicating the width of each column (starting at 1) or the starting and ending point of that column with a "-" between the start and end number. 39 | 40 | ```{r} 41 | col_positions <- c("1-1", "2-3", "4-5", "6-11") 42 | ``` 43 | 44 | ## col_names 45 | 46 | This is a vector of strings with names for the column. Only useful if the guide you're following to make this .sps file includes these names and you want to be exact. If you don't include this, it will just name the columns V1:Vnumber_of_columns. 47 | 48 | ```{r} 49 | col_names <- c("var1", "var2", "var3", "var4") 50 | ``` 51 | 52 | ## col_labels 53 | 54 | This is the same as col_names but each column name should be the descriptive name of the column. These names are the ones that will be used if real_names = TRUE in read_ascii_setup. 55 | 56 | ```{r} 57 | col_labels <- c("version_number", "victim_sex", "victim_race", "state") 58 | ``` 59 | 60 | ## value_labels 61 | 62 | This is a named vector with the column name as its own string followed by a string for each value-label pair in that column. The syntax is 'value = label'. For the column name, the label is blank so it appears 'column = '. For example, if 'sex' is the column name as it has value labels for M = Male and F = Female, the value_labels parameter will be: 63 | 64 | value_labels = c("sex =", "M = Male", "F = Female") 65 | 66 | ```{r} 67 | value_labels <- c("victim_sex = ", 68 | "MA = male", 69 | "FE = female", 70 | "UN = unknown", 71 | "victim_race = ", 72 | "WH = white", 73 | "BL = black", 74 | "IA = american indian or alaskan native", 75 | "AS = asian", 76 | "UN = unknown") 77 | ``` 78 | 79 | ## missing_values 80 | 81 | This is a vector of strings with the column name (can be either the name in col_names or col_labels but must be consistent) followed by all the values that represent missing values, each in its own string. 82 | 83 | ```{r} 84 | missing_values <- c("victim_sex", 85 | "-9", 86 | "-8", 87 | "victim_race", 88 | "-8") 89 | ``` 90 | 91 | ## Putting it all together 92 | 93 | ```{r eval = FALSE} 94 | asciiSetupReader::make_sps_setup(file_name = "setup_file_example", 95 | col_positions = col_positions, 96 | col_names = col_names, 97 | col_labels = col_labels, 98 | value_labels = value_labels, 99 | missing_values = missing_values) 100 | ``` 101 | 102 | -------------------------------------------------------------------------------- /vignettes/parsing-an-sps-or-sas-file.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Parsing an .sps or .sas file" 3 | author: "Jacob Kaplan" 4 | date: "`r Sys.Date()`" 5 | output: rmarkdown::html_vignette 6 | vignette: > 7 | %\VignetteIndexEntry{Parsing an .sps or .sas file} 8 | %\VignetteEngine{knitr::rmarkdown} 9 | %\VignetteEncoding{UTF-8} 10 | --- 11 | 12 | ```{r setup, include = FALSE} 13 | knitr::opts_chunk$set( 14 | collapse = TRUE, 15 | comment = "#>" 16 | ) 17 | ``` 18 | 19 | 20 | The `parse_setup` function is what this packages uses to convert the .sps or .sas setup files into an usable format for R. 21 | 22 | This will return a list of length 3 containing the objects "setup", "value_labels", and "missing". 23 | 24 | 25 | ```{r} 26 | # Using the example .sps setup file included with the package 27 | sps_name <- system.file("extdata", "example_setup.sps", 28 | package = "asciiSetupReader") 29 | example <- asciiSetupReader::parse_setup(sps_name) 30 | ``` 31 | 32 | ## setup 33 | 34 | The first object in the returned list is a data.frame with 4 columns and as many rows as there are columns in the data. The "column_number" column is the non-descriptive name of the column while the "column_name" is the descriptive name of the column. In `read_ascii_setup`, setting `use_clean_names` to TRUE will set the data column names to the "column_name" names, otherwise it will remain as the "column_number" names. Since the data is in fixed-width format, you need to know the location of each column. The "begin" and "end" columns in this object provide that location for each column in the data. 35 | 36 | ```{r} 37 | head(example$setup) 38 | ``` 39 | 40 | 41 | ## value_labels 42 | 43 | To make the data more compact, the data often provides values that represent a label. For example, in a column about participant's gender it may only include "M" and "F" which stands for "Male" and "Female". The setup file will say the M = Male and F = Female. The value labels tell us that we need to convert M to Male in the given column. This is a list of named vectors indicating the value and its corresponding label. If there are no value labels this object will be NULL. 44 | 45 | ```{r} 46 | example$value_labels[1:3] 47 | ``` 48 | There is one named vector for each column in the data that has value labels. We can see how many there are using `length()`. 49 | 50 | ```{r} 51 | length(example$value_labels) 52 | ``` 53 | 54 | ## missing 55 | 56 | The final object in the list a data.frame with two columns and as many rows as there are missing values in the data. The column "variable" indicates the column in the data and the column "values" says that the value in that row is to be replaced with NA. For example, if there are 10 columns in the data with missing values and each column has two missing values (e.g. -8 and -9) there will be 20 rows in this data.frame. A missing value is when the data includes a value that should be replaced with NA. For example, data often includes negative values such as -8 or -9 mean that that value is missing and should be NA. If there are no missing values this object will be NULL. 57 | 58 | 59 | ```{r} 60 | head(example$missing) 61 | ``` 62 | 63 | -------------------------------------------------------------------------------- /vignettes/setup_file_example.sps: -------------------------------------------------------------------------------- 1 | setup_file_example 2 | 3 | This setup file was created using the R package asciiSetupReader(version 2.0.0) on 2019-02-03 12:18:44. For any feedback or problems (or if the file looks odd), please make a report on https://github.com/jacobkap/asciiSetupReader/issues. For more information on this package see here: https://jacobkap.github.io/asciiSetupReader/. 4 | 5 | 6 | data list 7 | var1 1-1 8 | var2 2-3 9 | var3 4-5 10 | var4 6-11 11 | . 12 | 13 | variable labels 14 | var1 "version_number" 15 | var2 "victim_sex" 16 | var3 "victim_race" 17 | var4 "state" 18 | . 19 | 20 | value labels 21 | var2 22 | 'MA' "male" 23 | 'FE' "female" 24 | 'UN' "unknown" 25 | var3 26 | 'WH' "white" 27 | 'BL' "black" 28 | 'IA' "american indian or alaskan native" 29 | 'AS' "asian" 30 | 'UN' "unknown" 31 | . 32 | 33 | missing values 34 | var2 (-9, -8) 35 | var3 (-8) 36 | . 37 | 38 | 39 | execute 40 | --------------------------------------------------------------------------------