Thanks.
William
I think you need to be little bit ore specific in your question
because
I routinely read in "sas dataset"s. Of course, sas means Synthetic
Aperture Sonar to me, and my sas datasets are in a very simple
format.
--
steve
Sorry for the simplified description. The sas in my message refers to
the statistical analysis software. For example, we can create a simple
sas dataset using the following sas code.
Data Simple;
input id grade $;
cards;
1 A
2 B
3 A
4 C
;
run;
The result is that the dataset Simple is created and it has two
columns: id and grade.
I just wonder if there is a way using Fortran to read in the sas
dataset Simple. In the above example, the type of each column is not
declared. But the sas dataset I need to process using Fortran are well
formatted for each variable.
Thanks.
Williams
> Sorry for the simplified description. The sas in my message refers to
> the statistical analysis software. For example, we can create a simple
> sas dataset using the following sas code.
The last time that I used it (~20 years ago), SAS had a fortran API.
From a quick search on the SAS Institute website, I could not find any
reference to it, nor could I find anything from a search on the web.
However, there are plenty of jobs out there for people that know how
to do it! Thus, I suggest that you look in the SAS system
documentation for your system.
Paul
Thank you. I will look for those information in the SAS forum then. In
fact, if there are C# interfaces with SAS, I can learn something from
them, too.
William
On Nov 10, 11:50 pm, Paul Thomas <paul.richard.tho...@gmail.com>
wrote:
In the transport format? The standard format (.ssd, .sas7bdat etc) is
platform specific, IIRC, and has changed across versions. And variables
can be compressed etc. The way R does it is to generate a SAS script
that calls proc export. The resulting transport file is easier to
read, have a look at that code (SASxport.c in "foreign").
--
| David Duffy (MBBS PhD) ,-_|\
| email: dav...@qimr.edu.au ph: INT+61+7+3362-0217 fax: -0101 / *
| Epidemiology Unit, Queensland Institute of Medical Research \_,-._/
| 300 Herston Rd, Brisbane, Queensland 4029, Australia GPG 4D0B994A v
Sorry for the simplified description. The sas in my message refers to
the statistical analysis software. For example, we can create a simple
sas dataset using the following sas code.
Data Simple;
input id grade $;
cards;
1 A
2 B
3 A
4 C
;
run;
The result is that the dataset Simple is created and it has two
columns: id and grade.
I just wonder if there is a way using Fortran to read in the sas
dataset Simple. In the above example, the type of each column is not
declared. But the sas dataset I need to process using Fortran are well
formatted for each variable.
Thanks.
Williams
---> It's been ~ 15 years since I've worked with SAS.
1. What you have above does not create a separate dataset. Your data is IN
the job stream. Thats what "cards;" means. Back when data and programs were
punched on cards, this meant that your data cards were in the same deck as
your program cards.
2. SAS was able to read data in standard text files. These could be in fixed
column format or in a less restrictive format. Generally Fortran's formatted
I/O (including list directed) should be able to handle this.
3. SAS also had its own internal data files. These are somewhat like
Fortran's "unformatted" files. In order to read them, you need to have SAS.
4. SAS also supported a number of external file and database formats. On
personal computers, for example, they were able to import and export data
from dBaseII/III. By now they probably support APIs such as ODBC and SQL.
The short version is you need to read the manuals. Back when I was using
versions 5 and 6, SAS published a very nice introductory manual (expensive
but nice). Perhaps they now provide this type of documentation online.
--- Elliot
Thank you very much for the information. Without looking into
SASxport.c, just by reading your message, I believe that I can solve
the problem now.
Indeed, my problem can be solved by a simple system call to a sas
script inside Fortran. In the sas script, I can basically have a
simple proc export statement to export one sas dataset into a simple
text file. Fortran program can read and process the text file after
that.
I appreciate your advice. Thanks again.
William
On Nov 11, 1:09 am, David Duffy <dav...@orpheus.qimr.edu.au> wrote:
> I just wonder if there is a way using Fortran to read in a simple sas
> dataset?
William,
I have not used SAS much for about 10 yr, so I have forgotten a
lot. However, the way I used to move data from SAS to other
programs was to generate an ASCII file with the SAS "put"
statement in a NULL data step.
Then, only a simple Fortran program needed to read the data into
Fortran and do whatever calculations you need.
You will need to look at SAS data-export documentation if you
want to follow that route.
Good luck.
Mike
--
Mike Prager, NOAA, Beaufort, NC
Address spam-trapped; remove color to reply.
* Opinions expressed are personal and not represented otherwise.
* Any use of tradenames does not constitute a NOAA endorsement.
I assume you want to read a binary dataset such as sas7bdat from the
package formerly known as the Statistical Analysis System. I don't
think the SAS Institute provides any API for these since SAS 82 went
obsolete. There is a proprietary solution available from Circlesys
[ http://circlesys.com/ ] that you could probably link into a fortran
program, but I don't think there is any FOSS solution, nor are you
likely to be able to 'decrypt' the file without considerable effort
and talent.
If you have access to SAS itself, you want to write out the file in
ASCII or binary with a PUT statement, and read that with fortran read
statements. If you don't have access to SAS Circlesys also sells an
inexpensive program that will translate from SAS binary formats to
ASCII (or other binary formats). We have lots of experience with that
software and it works very well from the command line or the GUI, on
Windows or Unix.
Daniel Feenberg
feenberg isat nber dotte org
Keep in mind that if your dataset includes any missing data, you'll want
to know how it's encoded in the text file, and your Fortran program will
have to be able to interpret it properly.
Louis