DATA Step, Macro, Functions and more

Open SD2 file and convert to CSV

Accepted Solution Solved
Reply
Contributor
Posts: 28
Accepted Solution

Open SD2 file and convert to CSV

[ Edited ]

I want to open the .sd2 file . please help me to open the file.Is there any way to convert it into .csv format .

Please convert the file into a format so that i can open it ms-excel.

 


Accepted Solutions
Solution
‎10-13-2017 10:28 AM
Community Manager
Posts: 3,463

Re: Open SD2 file and convert to CSV

This is something that you can do yourself, for free, with the SAS Universal Viewer.  And usually I would not offer this "conversion service" on the communities -- after all, this space is a place to learn, not to get other people to do your work for you.

 

However, there are a few tricks to it, and for the benefit of others who might be looking for the steps to accomplish this, I've done this for you and attached some screen shots.

 

How to convert an SD2 file (SAS Version 6 data set) to CSV without having SAS installed

 

First, download and install the SAS Universal Viewer, x86 edition (32-bit).  It's free, and the download location is on support.sas.comYou must get the 32-bit version (win), not the wx6 version, because only the 32-bit data providers can read the older SD2 files.

 

uv_dl.png

 

To install the product, expand the ZIP file to a temp folder and then run SETUP.EXE.  Note that if you already have SAS software installed, you might run into some roadblocks if the SAS you have is newer than the components supplied in the Universal Viewer.  But...if you have SAS already, you don't need to use this method in the first place.  New versions of SAS can read/convert SD2 files via the V6 library engine.

 

Next, start the SAS Universal Viewer.  The program should be available from the Start menu.

 

Once running, use File->Open->SAS Data Set to select your data set to open.  You will need to change the file filter from "*.sas7bdat" to "*.sd2" and navigate to the folder that contains your data.  The data set will open in the workspace.

 

uv_1.png

 

Just above the data rows you'll find (a bit hidden) the Table menu.  Select it, and then select Save As...

 

uv_2.png

 

From the file type options in the Save As menu, select CSV and name the output file.  (Default Save As option is XML...not sure how popular that is, but whatever...)

 

For large files it will take a few moments to produce the CSV file.  But when done, you can navigate to the CSV in Windows Explorer and open in Excel.

 

uv_3.png

The raw values should all come over okay, but anything that relies on a user-defined format might not have the display value you expect.  Also, numeric IDs (like the CASENUM value shown in this example) might require some reformatting in Excel to display as you want them to.

 

If you want to automate this process outside of the SAS Universal Viewer, you can use the SAS Local OLE DB Data Providers and VB Script or PowerShell.  I've got examples on my blog.  Remember for SD2 files you need the 32-bit versions of these components, which run just fine on your Windows 64-bit edition.

 

Finally, as an exceptional public service, I've attached the ACCIDENT.CSV file (in a zip, as it's 11MB uncompressed).  I say "exceptional" because I don't want this to set a precedent Smiley Happy  Takeaway: SAS provides free tools for people who don't have SAS installed to get their data from SAS data sets.

View solution in original post

Attachment

All Replies
Community Manager
Posts: 3,463

Re: Open SD2 file and convert to CSV

If you don't have an installed version of SAS, you can use the SAS Universal Viewer to open your SAS data file and copy/export to another format.

 

Download is available here.

Contributor
Posts: 28

Re: Open SD2 file and convert to CSV

Posted in reply to ChrisHemedinger

I have never used SAS universal Viewer. Can anybody help me to change the attached accident.sd2 file to .csv format.(.sd2 to .csv)

Attachment
Solution
‎10-13-2017 10:28 AM
Community Manager
Posts: 3,463

Re: Open SD2 file and convert to CSV

This is something that you can do yourself, for free, with the SAS Universal Viewer.  And usually I would not offer this "conversion service" on the communities -- after all, this space is a place to learn, not to get other people to do your work for you.

 

However, there are a few tricks to it, and for the benefit of others who might be looking for the steps to accomplish this, I've done this for you and attached some screen shots.

 

How to convert an SD2 file (SAS Version 6 data set) to CSV without having SAS installed

 

First, download and install the SAS Universal Viewer, x86 edition (32-bit).  It's free, and the download location is on support.sas.comYou must get the 32-bit version (win), not the wx6 version, because only the 32-bit data providers can read the older SD2 files.

 

uv_dl.png

 

To install the product, expand the ZIP file to a temp folder and then run SETUP.EXE.  Note that if you already have SAS software installed, you might run into some roadblocks if the SAS you have is newer than the components supplied in the Universal Viewer.  But...if you have SAS already, you don't need to use this method in the first place.  New versions of SAS can read/convert SD2 files via the V6 library engine.

 

Next, start the SAS Universal Viewer.  The program should be available from the Start menu.

 

Once running, use File->Open->SAS Data Set to select your data set to open.  You will need to change the file filter from "*.sas7bdat" to "*.sd2" and navigate to the folder that contains your data.  The data set will open in the workspace.

 

uv_1.png

 

Just above the data rows you'll find (a bit hidden) the Table menu.  Select it, and then select Save As...

 

uv_2.png

 

From the file type options in the Save As menu, select CSV and name the output file.  (Default Save As option is XML...not sure how popular that is, but whatever...)

 

For large files it will take a few moments to produce the CSV file.  But when done, you can navigate to the CSV in Windows Explorer and open in Excel.

 

uv_3.png

The raw values should all come over okay, but anything that relies on a user-defined format might not have the display value you expect.  Also, numeric IDs (like the CASENUM value shown in this example) might require some reformatting in Excel to display as you want them to.

 

If you want to automate this process outside of the SAS Universal Viewer, you can use the SAS Local OLE DB Data Providers and VB Script or PowerShell.  I've got examples on my blog.  Remember for SD2 files you need the 32-bit versions of these components, which run just fine on your Windows 64-bit edition.

 

Finally, as an exceptional public service, I've attached the ACCIDENT.CSV file (in a zip, as it's 11MB uncompressed).  I say "exceptional" because I don't want this to set a precedent Smiley Happy  Takeaway: SAS provides free tools for people who don't have SAS installed to get their data from SAS data sets.

Attachment
Contributor
Posts: 28

Re: Open SD2 file and convert to CSV

[ Edited ]
Posted in reply to ChrisHemedinger

when i opened the accident.sd2 dataset in SAS universal viewer ,it gave the error "Unable to load the table ACCIDENT . one common cause is when table has an associated index which was not found".

Community Manager
Posts: 3,463

Re: Open SD2 file and convert to CSV

I didn't have any problems with SAS UV 1.4, 32-bit.  The 64-bit version would not open it -- I got the helpful message that SD2 files are not supported in the 64-bit version.  Sort of makes sense, as SD2 files were last used in SAS V6, firmly in the 32-bit (if not 16-bit) era.

Contributor
Posts: 28

Re: Open SD2 file and convert to CSV

Posted in reply to ChrisHemedinger
The above file you attached is accident_csv.zip file of my accident.sd2 file??
Community Manager
Posts: 3,463

Re: Open SD2 file and convert to CSV

Yes, that's what it is.

Contributor
Posts: 28

Re: Open SD2 file and convert to CSV

Posted in reply to ChrisHemedinger
thanks for helping me
Contributor
Posts: 28

Re: Open SD2 file and convert to CSV

Posted in reply to ChrisHemedinger

can .SSD file is opened using SAS universal viewer??

Community Manager
Posts: 3,463

Re: Open SD2 file and convert to CSV

[ Edited ]

Yes, but only with the 32-bit version of the SAS Universal Viewer -- 

 

Sorry @king_aj, scratch that.  I think the answer is No.  I misread your question and answered for SD2 files -- ssd01 (old-style Unix data sets) are not readable, at least in my tests.

Contributor
Posts: 28

Re: Open SD2 file and convert to CSV

Posted in reply to ChrisHemedinger

while opening the file gives error as shown in the image given below

IMG_20171027_000529.jpg

Contributor
Posts: 28

Re: Open SD2 file and convert to CSV

[ Edited ]

would you convert the attached files to .csv format? The files was not opened in SAS universal viewer ...please help...

Attachment
Contributor
Posts: 28

Re: Open SD2 file and convert to CSV

Posted in reply to ChrisHemedinger

sas univerasal viewer also gives errror in opening the .sd2 file

Contributor
Posts: 28

Re: Open SD2 file and convert to CSV

[ Edited ]

would you convert the attached files to .csv format? The files was not opened in SAS universal viewer ...please help @ChrisHemedinger

It is very helpful if someone converts the attached file to .csv.

Attachment
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 35 replies
  • 1803 views
  • 12 likes
  • 3 in conversation