BookmarkSubscribeRSS Feed
vijay2583
Calcite | Level 5

Hello All,

I have a requirement to extract the data from sqlserver 2005 database into SAS Datasets. Iam new to SAS Dataset formats.

I studied that for a SAS Dataset there will be two files

1) .DAT File which contains the data

2)  .SAS File which contains the control structure.

Now my query is do we have to generate both files or .DAT file is enough?

Does any one have idea of generating those files. Iam using C#.Net for extraction.


Please point me to any resources regarding this.

Thank you Very much for your time.

Thanks,

Vijay

7 REPLIES 7
Doc_Duke
Rhodochrosite | Level 12

SAS can read SQL/Server databases directly, so there is no need for the external program.

The way you are describing would generate some sort of text file and the SAS code for reading it.  Unless you put a lot of effort into generating the SAS code, you are going to lose a lot of the metadata from SQL/Server.  Technically, you don't "need" the SAS code.  However, if you don't you will need other documentation for the .DAT file and you will have unhappy users.

Doc Muhlbaier

Duke

vijay2583
Calcite | Level 5

Hello Doc Muhibaier,

Thank you for your response.

Althogh SAS can read SQL/Server databases directly it willn't work for us.

We can't provide access to SQL Server database for the SAS Team. They are of different consultants. The only option we have is to provide the data in SAS Datasets.

Now my issue is how to generate SAS Datasets using C# programming.

Thanks,

VIjay

PGStats
Opal | Level 21

What are you trying to do? Use a C# program to create a SAS dataset? Get SAS to analyze some data for your C# program? Something else?

PG

PG
vijay2583
Calcite | Level 5

HI PG,

We are trying to create a SAS dataset using C# program. Is there any suggestions on this?

 

Thanks,

VIjay

vijay2583
Calcite | Level 5

Hi Ksharp,

The link you provide is to achive my task using SAS programming. But my requirement is to use the C#.Net programming.

Thanks,

Vijay

Tom
Super User Tom
Super User

If you do not have SAS and/or SAS cannot access your database then the easiest thing to do is to generate a raw data file (frequently called an ASCII file) and a program that can read it.  Mostly likely it is easiest to generate a CSV file as that format is pretty well known.  But watch out for issues like embedded CR of LF characters in your data.  If the data is very well formatted the you might be able to get away with only the CSV file.  But when you have things like missing values, character variables with only digits so that they look like numbers or characters fields with wildly varing length the CSV can be hard to interpret.  If you users are experienced programmers then you might just generate the CSV file and data dictionary that decribes the variables.  An experienced user can use that to write their own program to read the CSV or at least QC the results of PROC IMPORTs attempt to determine the variable types. But if you need to it should not be difficult to generate a simple SAS data step to read in your data based on the metadata you have about the variables.

You might also want to look at using a utility such as STAT/Transfer that can convert the files for you on your machine.  That way you could generate SAS datasets and send those.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Health and Life Sciences Learning

 

Need courses to help you with SAS Life Sciences Analytics Framework, SAS Health Cohort Builder, or other topics? Check out the Health and Life Sciences learning path for all of the offerings.

LEARN MORE

Discussion stats
  • 7 replies
  • 2705 views
  • 0 likes
  • 5 in conversation