PHP Classes

SAS to MySQL: Extract data dictionaries from SAS file into MySQL

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 67 All time: 10,326 This week: 455Up
Version License PHP version Categories
sas2sql 1.0Freely Distributable5PHP 5, Databases, Files and Folders, P...


This class can extract data dictionaries from SAS file into MySQL.

It can parse SAS files and extract values of data dictionaries (Format, Input, Label).

The class creates a table on MySQL database to insert the extracted data.

It replaces numeric data values with full text data.

The class can optimize data replacing VARCHAR default into appropriate INT or ENUM for easier data browsing. It also split tables along columns when there are too many columns during optimization.

Innovation Award
PHP Programming Innovation award nominee
January 2017
Number 12
SAS is a programming language used for statistical analysis.

Its source code may include the definition of arrays of data, also known as data dictionaries.

This package can extract data dictionaries from SAS files into a MySQL database.

Manuel Lemos
Picture of Greg Neyman
  Performance   Level  
Name: Greg Neyman <contact>
Classes: 2 packages by
Country: United Kingdom
Age: 46
All time rank: 4203187 in United Kingdom
Week rank: 286 Up10 in United Kingdom Up
Innovation award
Innovation award
Nominee: 2x


The definition files I've built this off of are
The data files are

Hilariously the public version of ed13for.txt has an error in it. This is good, it prompted me to write in error checking into the class.
$link=mysqli_connect("localhost","root","","nhamcs") or die($link->error);
$thingy= new sas2sql();
"format"=>"ed14"."for.txt","input"=>"ed14"."inp.txt","label"=>"ed14"."lab.txt","data"=>"ED2014") as $k=>$v){
explode(";",$thingy->query) as $query) {
trim($query))) $link->query($query) or die($link->error);
explode(";",$thingy->split_results($result->fetch_all(),12)) as $query) {
trim($query))) $link->query($query) or die($link->error);
$result=$link->query("SHOW TABLES WHERE `Tables_in_nhamcs` LIKE 'ed2014%'") or die($link->error);
$tables as $table) {
explode(";",$thingy->optimise_results($result->fetch_all(),$table[0])) as $query) {
trim($query))) $link->query($query) or die($link->error.$table[0]);

  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Example Script
Plain text file sas2sql.php Class Class Source

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:10,326
This week:455Up