| Title: | Format Student Data for the National Student Clearinghouse |
| Version: | 1.1.8 |
| Date: | 2026-09-07 |
| Description: | Formats student records for submission to the National Student Clearinghouse. The package creates the required header, detail, and trailer rows and writes tab-delimited TXT and CSV files. |
| License: | MIT + file LICENSE |
| RoxygenNote: | 7.2.3 |
| Encoding: | UTF-8 |
| Imports: | readxl, stringi |
| NeedsCompilation: | no |
| Packaged: | 2026-09-07 14:00:58 UTC; BKlauth |
| Author: | Bo Klauth |
| Maintainer: | Bo Klauth <bklauth@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-09-15 12:00:18 UTC |
Format Student Data for National Student Clearinghouse Submission
Description
Format student records into header, detail and trailer rows and write tab-delimited TXT and CSV files. It prepares files; it does not upload them.
Usage
format_data(
school_code,
branch_code,
school_name,
file_creation_date,
query_option,
file_dir,
input_file_name,
suffix
)
Arguments
school_code |
Institution's six-digit code supplied as character text to preserve leading zeros. |
branch_code |
Two-digit branch code supplied as character text. |
school_name |
Full institution name. |
file_creation_date |
Header creation date in YYYYMMDD format. |
query_option |
Query code: CO, DA, PA or SE. CO requires a single search date in the input. |
file_dir |
Existing directory containing input files and receiving output. |
input_file_name |
A seven-column data frame, or the filename of a headerless XLSX, XLS, tab-delimited TXT or CSV file in file_dir. Columns, in order: first name, middle initial, last name, name suffix, date of birth, search date, and requester-return identifier. Birth dates may be supplied as dates or common date strings and are written in YYYYMMDD format. File input is read as text so leading zeros are preserved. |
suffix |
Text appended to the output filename after date and query code. |
Details
Latin accents in the four name fields are transliterated to ASCII. Records with missing or empty first/last names are excluded. The trailer count includes the header and trailer.
In this update, punctuation is removed from all input fields, including IDs. File input is read as text. For an R data frame, the identifier column must be character; zeros lost before the call cannot be recovered. Whitespace-only names are not excluded, and an input with no retained records is not supported. The existing date check rejects dates fewer than 60 days before the current system date. NSC only allows search dates within at least 60 days of the current system date.
Value
A data frame with 12 columns containing header, retained student detail rows and trailer. TXT and CSV files are also written to file_dir.
References
To cite this package in APA style, run citation("NSC") in R.
Examples
students <- data.frame(
first = paste0("Student", seq_len(11)),
middle = "A",
last = "Example",
suffix = "", dob = "2000-01-01",
search = "2020-01-01",
id = sprintf("%05d", seq_len(11)))
destination <- tempfile("NSC-example-")
dir.create(destination)
formatted <- format_data(
school_code = "001234",
branch_code = "00",
school_name = "Example College",
file_creation_date = format(Sys.Date(), "%Y%m%d"),
query_option = "SE",
file_dir = destination,
input_file_name = students,
suffix = "example")
dim(formatted)