getting your data into SAS

Getting data into SAS was always a great source of headache for me, because I am not familiar with SAS. There were some items in the wiki-book, but when I referred people to those they said that it was not complete and/or that that was not what they were looking for. But in February 2014 Linas Silvas published some great scripts! Lindsay Stevens modified them a bit and put them in his repository and they were welcomed with a loud hurray. Well, from me at last. I must confess that it took me some time to get them working, but once I had done some transformations it was a breeze. I even managed to "minify" the script a bit, so that it is easier to use it.


You can download the scripts from Lindsay's Github, but you can also use this zip-file. Then unzip the lot and put it in a folder:

fig. 1: the contents of the folder

Now you are ready to transform your dataset, so go to your OpenClinica and create a dataset and extract it to CDISC ODM XML 1.3: any flavor will do. Download the zip and unzip the xml to the same folder where you unzipped the script files. Personally I prefer to rename the file to something short like total_20141031.xml

the big transformations

With all this in place we can run the scripts and this is done by opening a command prompt as administrator. The script is a Powershell script, so we first go to the right drive and folder and then we start Powershell. We have to set the right execution policy and this is done by Set-ExecutionPolicy Unrestricted -Scope Process. The script only needs one parameter and that is the name of the xml-file with the dataset, so in our case .\From_XML_to_SAS_xsl_transforms.ps1 "total_20141031.xml"

fig. 2: calling the script

You then leave Powershell with "exit" and the command-prompt with another "exit". In your folder you now should have: mapout_total_20141031.xml, formatout_total_20141031.xml and data_total_20141031.xml

how it works

In the zip file is another ps1-file, called powershell_perform_SAS_xsl_transforms.ps1 and this is Linas' original script. When you open it you see that it needs seven parameters. I'm prone to make typo's, so I rewrote that to have the xsl-names, because they are already set, plus generated names for the output-files.
There is also the file xml_convert_dynamic_lookup.xsl which can be used to give your groupsids more friendly names. This file has to be modified manually, before you do the transformations.

Other how-to-pages can be found here.

this page was last reviewed November 2014