Thread: [R-gregmisc-users] SF.net SVN: r-gregmisc: [1110] trunk/SASxport
Brought to you by:
warnes
From: <wa...@us...> - 2007-08-03 00:35:41
|
Revision: 1110 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1110&view=rev Author: warnes Date: 2007-08-02 17:35:39 -0700 (Thu, 02 Aug 2007) Log Message: ----------- More modifications. Should now work for most R data types Modified Paths: -------------- trunk/SASxport/NAMESPACE trunk/SASxport/R/write.xport.R trunk/SASxport/R/xport.character.R trunk/SASxport/R/xport.file.header.R trunk/SASxport/R/xport.member.header.R trunk/SASxport/R/xport.namestr.R trunk/SASxport/src/SASxport.so trunk/SASxport/src/writeSAS.c Added Paths: ----------- trunk/SASxport/R/fromSASDate.R trunk/SASxport/R/parseFormat.R trunk/SASxport/R/toSAS.R trunk/SASxport/man/toSAS.Rd Modified: trunk/SASxport/NAMESPACE =================================================================== --- trunk/SASxport/NAMESPACE 2007-08-03 00:35:07 UTC (rev 1109) +++ trunk/SASxport/NAMESPACE 2007-08-03 00:35:39 UTC (rev 1110) @@ -1,5 +1,14 @@ export( - write.xport + write.xport, + toSAS ) +S3method(toSAS,numeric) +S3method(toSAS,logical) +S3method(toSAS,character) +S3method(toSAS,factor) +S3method(toSAS,POSIXt) +S3method(toSAS,Date) +S3method(toSAS,default) + useDynLib(SASxport) Added: trunk/SASxport/R/fromSASDate.R =================================================================== --- trunk/SASxport/R/fromSASDate.R (rev 0) +++ trunk/SASxport/R/fromSASDate.R 2007-08-03 00:35:39 UTC (rev 1110) @@ -0,0 +1,15 @@ +fromSASDate <- function( sDate ) + { + sasBase <- as.Date(strptime("01/01/1960 0:00:00", "%m/%d/%Y %H:%M:%S", tz="GMT")) # days + sasBase + sDate + } + + +fromSASDateTime <- function( sDateTime ) + { + sasBaseSeconds <- as.numeric(ISOdatetime(1960,1,1,0,0,0) - 0) + retval <- sDateTime + sasBaseSeconds + class(retval) <- c("POSIXt","POSIXct") + retval + } + Added: trunk/SASxport/R/parseFormat.R =================================================================== --- trunk/SASxport/R/parseFormat.R (rev 0) +++ trunk/SASxport/R/parseFormat.R 2007-08-03 00:35:39 UTC (rev 1110) @@ -0,0 +1,41 @@ +## Convert SAS format specification string into format name, length, and digits +parseFormat <- function(format) + { + retval <- list("name"="", "len"=0, "digits"=0) + + + if( !is.null(format) && (length(format)==1) && (format > "") ) + { + index <- regexpr("[0-9]+", format) + if(index==-1) + { + retval$name <- format + retval$len <- 0 + retval$digits <- 0 + } + else + { + retval$name <- substr(format,0,index-1)[1] + + lenStr <- substr(format,index, nchar(format)) + + index <- regexpr("\\.", lenStr) + if(index==-1) + { + retval$len <- as.numeric(lenStr) + retval$digits <- 0 + } + else + { + retval$len <- as.numeric(substr(lenStr, 0, index-1)) + retval$digits <- as.numeric(substr(lenStr, index+1, nchar(lenStr))) + } + } + + if(is.na(retval$len)) retval$len <- 0 + if(is.na(retval$digits)) retval$digits <- 0 + + } + + return(retval) + } Added: trunk/SASxport/R/toSAS.R =================================================================== --- trunk/SASxport/R/toSAS.R (rev 0) +++ trunk/SASxport/R/toSAS.R 2007-08-03 00:35:39 UTC (rev 1110) @@ -0,0 +1,55 @@ +toSAS <- function(x, format) + UseMethod("toSAS") + +toSAS.numeric <- function(x, format="") + { + retval <- as.numeric(x) + attr(retval, "format")=format + retval + } + +toSAS.logical <- function(x, format="") + { + retval <- as.character(x) + attr(retval, "format")=format + retval + } + + +toSAS.character <- function(x, format="") + { + retval <- as.character(x) + attr(retval, "format")=format + retval + } + +toSAS.factor <- function(x, format="") + { + retval <- as.character(x) + attr(retval, "format")=format + retval + } + +toSAS.POSIXt <- function( x, format="DATETIME16." ) + { + sasBaseSeconds <- as.numeric(ISOdatetime(1960,1,1,0,0,0)) + retval <- unclass(as.POSIXct(x)) - sasBaseSeconds # sasBaseSeconds is negative + attr(retval,"format") <- format + retval + } + +toSAS.Date <- function(x, format="DATE9." ) + { + sasBase <- as.Date(strptime("01/01/1960", "%m/%d/%Y", tz="GMT")) # days + retval <- as.numeric( as.Date(x) - sasBase) + attr(retval, "format") <- format + retval + } + +toSAS.default <- function(x, format="") + { + retval <- as.character(x) + attr(retval, "format")=format + retval + } + Modified: trunk/SASxport/R/write.xport.R =================================================================== --- trunk/SASxport/R/write.xport.R 2007-08-03 00:35:07 UTC (rev 1109) +++ trunk/SASxport/R/write.xport.R 2007-08-03 00:35:39 UTC (rev 1110) @@ -88,9 +88,14 @@ scat("", i , "...") var <- df[[i]] - # Convert factors to character strings - if(is.factor(var)) df[[i]] <- var <- as.character(var) + # get attribute information before any transformations!" + varLabel <- attr(var, "label") + varFormat <- attr(var, "format") + varIFormat <- attr(var, "iformat") + # Convert R object to SAS object + df[[i]] <- var <- toSAS(var) + # compute variable length if(is.character(var)) varLen <- max(8, max( nchar(var) ) ) @@ -100,12 +105,33 @@ # fill in variable offset and length information offsetTable[i, "len"] <- varLen offsetTable[i, "offset"] <- lenIndex + + + + # parse format and iformat + formatInfo <- parseFormat( varFormat) + iFormatInfo <- parseFormat( varIFormat) + + + # write the entry - out( xport.namestr( - var=var, varName=i, varNum=varIndex, varPos=lenIndex, - varLength=varLen - ) ) + out( + xport.namestr( + var=var, + varName=i, + varNum=varIndex, + varPos=lenIndex, + varLength=varLen, + varLabel=varLabel, + fName = formatInfo$name, + fLength = formatInfo$len, + fDigits = formatInfo$digits, + iName = iFormatInfo$name, + iLength = iFormatInfo$len, + iDigits = iFormatInfo$digits, + ) + ) # increment our counters lenIndex <- lenIndex + varLen @@ -115,7 +141,8 @@ scat("Done.") # Space-fill to 80 character record end - fillSize <- spaceUsed %% 80 + fillSize <- 80 - (spaceUsed %% 80) + if(fillSize==80) fillSize <- 0 out( xport.fill( TRUE, fillSize ) ) scat("Write header for data block ...") @@ -123,7 +150,6 @@ scat("Done") scat("Write data ... "); - counter <- 1 spaceUsed <- 0 for(i in 1:nrow(df) ) for(j in 1:ncol(df) ) @@ -140,9 +166,11 @@ spaceUsed <- spaceUsed + valLen } - fillSize <- spaceUsed %% 80 - out( xport.fill(FALSE, fillSize ) ) + fillSize <- 80 - (spaceUsed %% 80) + if(fillSize==80) fillSize <- 0 + out( xport.fill(TRUE, fillSize ) ) + scat("Done.") } Modified: trunk/SASxport/R/xport.character.R =================================================================== --- trunk/SASxport/R/xport.character.R 2007-08-03 00:35:07 UTC (rev 1109) +++ trunk/SASxport/R/xport.character.R 2007-08-03 00:35:39 UTC (rev 1110) @@ -1,6 +1,8 @@ xport.character <- function( value, width ) { if(length(value)!=1) stop("Only a single character value is permitted.") + + if(is.na(value)) value <- "" .C("fill_character_field", value = as.character(value), Modified: trunk/SASxport/R/xport.file.header.R =================================================================== --- trunk/SASxport/R/xport.file.header.R 2007-08-03 00:35:07 UTC (rev 1109) +++ trunk/SASxport/R/xport.file.header.R 2007-08-03 00:35:39 UTC (rev 1110) @@ -2,10 +2,10 @@ function( cDate=Sys.time(), mDate=cDate, sasVer="7.00", osType="Unknown" ) { .C("fill_file_header", - cDate = xport.dateFMT(cDate), # creation date - mDate = xport.dateFMT(mDate), # modification date + cDate = xport.dateFMT(cDate), # Creation date + mDate = xport.dateFMT(mDate), # Modification date sasVer = toupper(as.character(sasVer)), # SAS version number - osType = toupper(as.character(osType)), # operating system + osType = as.character(osType), # Operating System (can include lowercase) PACKAGE="SASxport" ) Modified: trunk/SASxport/R/xport.member.header.R =================================================================== --- trunk/SASxport/R/xport.member.header.R 2007-08-03 00:35:07 UTC (rev 1109) +++ trunk/SASxport/R/xport.member.header.R 2007-08-03 00:35:39 UTC (rev 1110) @@ -4,7 +4,7 @@ .C("fill_member_header", dfName = toupper(as.character(dfName)), # Name of data set sasVer = toupper(as.character(sasVer)), # SAS version number - osType = toupper(as.character(osType)), # Operating System + osType = as.character(osType), # Operating System (can include lowercase) cDate = xport.dateFMT(cDate), # Creation date mDate = xport.dateFMT(mDate), # modification date PACKAGE="SASxport" Modified: trunk/SASxport/R/xport.namestr.R =================================================================== --- trunk/SASxport/R/xport.namestr.R 2007-08-03 00:35:07 UTC (rev 1109) +++ trunk/SASxport/R/xport.namestr.R 2007-08-03 00:35:39 UTC (rev 1110) @@ -33,13 +33,8 @@ else varLength <- 8 -# if(missing(varLabel) || is.null(varLabel) ) -# { -# varLabel <- attr(var, "label") -# if(is.null(varLabel)) -# varLabel <- varName -# } - varLabel="" + if( missing(varLabel) || is.null(varLabel) ) + varLabel <- "" just <- match.arg(just) if(just=="left") Added: trunk/SASxport/man/toSAS.Rd =================================================================== --- trunk/SASxport/man/toSAS.Rd (rev 0) +++ trunk/SASxport/man/toSAS.Rd 2007-08-03 00:35:39 UTC (rev 1110) @@ -0,0 +1,90 @@ +\name{toSAS.default} +alias{toSAS} +alias{toSAS.numeric} +alias{toSAS.logical} +alias{toSAS.character} +alias{toSAS.factor} +alias{toSAS.POSIXt} +alias{toSAS.Date} +alias{toSAS.default} +\title{Convert R data object for storage in SAS xport file} +\description{ + The \code{toSAS} methods control how R objects and data types are + represented when stored into a SAS xport format file using + \code{write.xport}. +} +\usage{ +toSAS(x, format) +\method{toSAS}{default}(x, format="") +\method{toSAS}{numeric}(x, format="") +\method{toSAS}{logical}(x, format="") +\method{toSAS}{character}(x, format="") +\method{toSAS}{factor}(x, format="") +\method{toSAS}{POSIXt}( x, format="DATETIME16." ) +\method{toSAS}{Date}(x, format="DATE9." ) +} +\arguments{ + \item{x}{ Object to be converted } + \item{format}{SAS format name} +} +\details{ + To add support for a new object type, create an appropriate + \code{toSAS} method. This method must convert the object data to + either an object of type "numeric" or type "character", and should add + an attribute named "format" to the object providing an appropriate SAS + format string or "" (indicating the default SAS format). +} +\value{ + A vector of type "character" or of type "numeric", with an attribute + named "lable" containing the SAS format specification. +} +\author{ Gregory R. Warnes \email{gr...@ra...} } +\seealso{ + \code{\link{write.xport}}, + \code{\link{read.xport}}, + \code{\link{lookup.xport}} +} +\examples{ + +#### +## See how an R date object will be stored in a SAS xport file: +#### + +dateObj <- ISOdate(2007,08,01,10,14,37) +dateObj + +sasObj <- toSAS(dateObj) +str(sasObj) + +#### +## Create a new R object class based on factor to hold color names +#### +colorFactor <- function(x) # constructor + { + retval <- factor(x, levels=c("Red","Green","Blue") ) + class(retval) <- c("colorFactor","factor") + retval + } + +## create one and look at it +cf <- colorFactor( c("Red","Red","Blue",NA) ) + + +## See how it will be represented in a SAS xport file +toSAS(cf) +class(toSAS(cf)) + +## Create a new conversion function to store as a RGB hex value +toSAS.colorFactor <- function(x, format="") +{ + retval <- ifelse(x=="Red", "#FF0000", ifelse(x=="Green", "#00FF00", "#0000FF") ) + attr(retval, "format") <- format + retval +} + +## see it in action +toSAS(cf) + +} +\keyword{manip} +\keyword{IO} Modified: trunk/SASxport/src/SASxport.so =================================================================== (Binary files differ) Modified: trunk/SASxport/src/writeSAS.c =================================================================== --- trunk/SASxport/src/writeSAS.c 2007-08-03 00:35:07 UTC (rev 1109) +++ trunk/SASxport/src/writeSAS.c 2007-08-03 00:35:39 UTC (rev 1110) @@ -328,7 +328,6 @@ static char numeric_NA[8] = {0x2e,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; memcpy(raw_buffer, numeric_NA, 8); - REVERSE(raw_buffer, 8); raw_buffer_used = 8; return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-08-03 01:29:42
|
Revision: 1114 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1114&view=rev Author: warnes Date: 2007-08-02 18:29:24 -0700 (Thu, 02 Aug 2007) Log Message: ----------- Correct some typos. Modified Paths: -------------- trunk/SASxport/man/toSAS.Rd trunk/SASxport/src/cnxptiee.c trunk/SASxport/src/writeSAS.c Modified: trunk/SASxport/man/toSAS.Rd =================================================================== --- trunk/SASxport/man/toSAS.Rd 2007-08-03 00:40:42 UTC (rev 1113) +++ trunk/SASxport/man/toSAS.Rd 2007-08-03 01:29:24 UTC (rev 1114) @@ -1,12 +1,12 @@ \name{toSAS.default} -alias{toSAS} -alias{toSAS.numeric} -alias{toSAS.logical} -alias{toSAS.character} -alias{toSAS.factor} -alias{toSAS.POSIXt} -alias{toSAS.Date} -alias{toSAS.default} +\alias{toSAS} +\alias{toSAS.numeric} +\alias{toSAS.logical} +\alias{toSAS.character} +\alias{toSAS.factor} +\alias{toSAS.POSIXt} +\alias{toSAS.Date} +\alias{toSAS.default} \title{Convert R data object for storage in SAS xport file} \description{ The \code{toSAS} methods control how R objects and data types are Modified: trunk/SASxport/src/cnxptiee.c =================================================================== --- trunk/SASxport/src/cnxptiee.c 2007-08-03 00:40:42 UTC (rev 1113) +++ trunk/SASxport/src/cnxptiee.c 2007-08-03 01:29:24 UTC (rev 1114) @@ -1,6 +1,6 @@ #include <stdio.h> #include <string.h> -#import "cnxptiee.h" +#include "cnxptiee.h" Modified: trunk/SASxport/src/writeSAS.c =================================================================== --- trunk/SASxport/src/writeSAS.c 2007-08-03 00:40:42 UTC (rev 1113) +++ trunk/SASxport/src/writeSAS.c 2007-08-03 01:29:24 UTC (rev 1114) @@ -27,11 +27,9 @@ #include <R.h> #include <Rinternals.h> -//#import "cnxptiee.h" - extern int cnxptiee(char *from, int fromtype, char *to, int totype); -#import "writeSAS.h" +#include "writeSAS.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-08-03 01:44:25
|
Revision: 1115 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1115&view=rev Author: warnes Date: 2007-08-02 18:44:23 -0700 (Thu, 02 Aug 2007) Log Message: ----------- Add "assert" function to avoid dependenct on gtools. Added Paths: ----------- trunk/SASxport/R/assert.R trunk/SASxport/man/assert.Rd Added: trunk/SASxport/R/assert.R =================================================================== --- trunk/SASxport/R/assert.R (rev 0) +++ trunk/SASxport/R/assert.R 2007-08-03 01:44:23 UTC (rev 1115) @@ -0,0 +1,6 @@ +## useful function, raises an error if the FLAG expression is FALSE +assert <- function( FLAG ) + { + if(!all(FLAG)) + stop("Failed Assertion") + } Added: trunk/SASxport/man/assert.Rd =================================================================== --- trunk/SASxport/man/assert.Rd (rev 0) +++ trunk/SASxport/man/assert.Rd 2007-08-03 01:44:23 UTC (rev 1115) @@ -0,0 +1,42 @@ +\name{assert} +\alias{assert} +\title{Generate an error if an expression is not true.} +\description{ + Generate an error if an expression is not true. +} +\usage{ +assert(FLAG) +} +\arguments{ + \item{FLAG}{ Expression that should evaluate to a boolean vector} +} +\details{ + Assert generate an error if its aregument does not evaluate to + boolean (vector) containing only \code{TRUE} values. This is useful + for defensinve programming as it provides a mechanism for checking + that certain facts, the 'assertions', do in fact hold. Checking of + 'assertions' is an important tool in the development of robust program + code. +} +\value{ + None. Evaluated only for its side effect. +} +\author{Gregory R. Warnes \email{wa...@bs...} } +\seealso{ \code{\link[base]{stop}}, \code{\link[base]{warning}} } +\examples{ + +## Trivial example +posSqrt <- function(x) + { + assert(x>=0) + sqrt(x) + } + +posSqrt(1:10) # works fine, no messages +\dontrun{ +posSqrt(-5:5) # generates an error, since the asssertion is not met +} + + +} +\keyword{programming} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-08-08 18:54:55
|
Revision: 1126 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1126&view=rev Author: warnes Date: 2007-08-08 11:54:43 -0700 (Wed, 08 Aug 2007) Log Message: ----------- Updates Modified Paths: -------------- trunk/SASxport/DESCRIPTION trunk/SASxport/NAMESPACE Modified: trunk/SASxport/DESCRIPTION =================================================================== --- trunk/SASxport/DESCRIPTION 2007-08-08 18:54:23 UTC (rev 1125) +++ trunk/SASxport/DESCRIPTION 2007-08-08 18:54:43 UTC (rev 1126) @@ -9,5 +9,5 @@ write SAS export files. The creation of this package was funded by Metrum Institute <http://metruminstitute.org>. License: GPL 2.0 or later -Imports: methods +Imports: methods, foreign, chron Modified: trunk/SASxport/NAMESPACE =================================================================== --- trunk/SASxport/NAMESPACE 2007-08-08 18:54:23 UTC (rev 1125) +++ trunk/SASxport/NAMESPACE 2007-08-08 18:54:43 UTC (rev 1126) @@ -1,19 +1,41 @@ useDynLib(SASxport, .registration=TRUE) +importFrom(foreign, read.xport, lookup.xport) +importFrom(chron, chron) + export( - assert, toSAS, lookup.xport, read.xport, - write.xport + write.xport, + "label", + "label<-", + + "units", + "units<-", + + "formats", + "formats<-", + + "iformat", + "iformat<-" ) -S3method(toSAS,numeric) -S3method(toSAS,logical) -S3method(toSAS,character) -S3method(toSAS,factor) -S3method(toSAS,POSIXt) -S3method(toSAS,Date) -S3method(toSAS,default) +S3method(toSAS, numeric) +S3method(toSAS, logical) +S3method(toSAS, character) +S3method(toSAS, factor) +S3method(toSAS, POSIXt) +S3method(toSAS, Date) +S3method(toSAS, default) +S3method(label, default) +S3method(units, default) +S3method(formats, default) +S3method(iformat, default) +S3method("label<-", default) +S3method("units<-", default) +S3method("formats<-", default) +S3method("iformat<-", default) + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-08-09 23:29:04
|
Revision: 1133 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1133&view=rev Author: warnes Date: 2007-08-09 16:29:01 -0700 (Thu, 09 Aug 2007) Log Message: ----------- More changes, esp to lookup.xport() and friends Modified Paths: -------------- trunk/SASxport/DESCRIPTION trunk/SASxport/NAMESPACE trunk/SASxport/man/lookup.xport.Rd trunk/SASxport/man/read.xport.Rd trunk/SASxport/man/units.Rd Added Paths: ----------- trunk/SASxport/TODO Modified: trunk/SASxport/DESCRIPTION =================================================================== --- trunk/SASxport/DESCRIPTION 2007-08-09 23:28:42 UTC (rev 1132) +++ trunk/SASxport/DESCRIPTION 2007-08-09 23:29:01 UTC (rev 1133) @@ -3,11 +3,17 @@ Title: Read and write SAS export files Version: 0.99.1 Date: 2007-07-28 -Author: Gregory R. Warnes <gr...@ra...> +Author: Gregory R. Warnes <gr...@ra...>, + includes code from Frank E. Harrell, Jr.'s Hmisc package. Maintainer: Gregory R. Warnes <gr...@ra...> Description: This package provides functions to read, list contents of, and - write SAS export files. The creation of this package was funded - by Metrum Institute <http://metruminstitute.org>. + write SAS export files. This package was created by Random + Technologies LLC <http://random-technologies-llc.com> with funding + by Metrum Institute <http://metruminstitute.org>. + . + Technical support contracts and other services for for R, this + package, and other packages are available from Random Technologies + LLC <http://random-technologies-llc.com>. License: GPL 2.0 or later Imports: methods, foreign, chron Modified: trunk/SASxport/NAMESPACE =================================================================== --- trunk/SASxport/NAMESPACE 2007-08-09 23:28:42 UTC (rev 1132) +++ trunk/SASxport/NAMESPACE 2007-08-09 23:29:01 UTC (rev 1133) @@ -39,3 +39,7 @@ S3method("formats<-", default) S3method("iformat<-", default) +S3method(print, lookup.xport) +S3method(summary, lookup.xport) +S3method(print, summary.lookup.xport) + Added: trunk/SASxport/TODO =================================================================== --- trunk/SASxport/TODO (rev 0) +++ trunk/SASxport/TODO 2007-08-09 23:29:01 UTC (rev 1133) @@ -0,0 +1,17 @@ +- Write replacements for SAS's REVERSE function, which corrects for + differences in endianness, and cnxptieee function, which is used to + convert from the IBM floating point representation to the IEEE + representation. + +- Write test routines for very large files, particulary very large + files with columns contiaining almost all missing values. + +- Test that created files are properly read by SAS, particulary when + the SAS version and OS version are set to the default values I've + provided. + +- Check function for 64 bit versions of R. I suspect that there may + be variable size issues for some int fields for write.xport(). + +- + Modified: trunk/SASxport/man/lookup.xport.Rd =================================================================== --- trunk/SASxport/man/lookup.xport.Rd 2007-08-09 23:28:42 UTC (rev 1132) +++ trunk/SASxport/man/lookup.xport.Rd 2007-08-09 23:29:01 UTC (rev 1133) @@ -1,33 +1,75 @@ \name{lookup.xport} \alias{lookup.xport} +\alias{print.lookup.xport} +\alias{summary.lookup.xport} +\alias{print.summary.lookup.xport} \title{Lookup Information on a SAS XPORT Format Library} \description{ - Scans a file as a SAS XPORT format library and returns a list - containing information about the SAS library. + Describe the contents of an SAS XPORT format file. } \usage{ lookup.xport(file) +\method{print}{lookup.xport}(x, ...) +\method{summary}{lookup.xport}(x, ...) +\method{print}{summary.lookup.xport}(x, ...) } \arguments{ - \item{file}{character variable with the name of the file to read. The - file must be in SAS XPORT format.} + \item{file}{Character string specifying the name or URL of a SAS XPORT file.} + \item{x}{Object to be printed or summarized} + \item{...}{Optional arguments} } \value{ - A list with one component for each dataset in the XPORT format library. + \code{lookup.xport} returs a list with one component for each dataset + in the XPORT format library. + + \code{summary.lookup.xport} returns a + single data frame containing the following component + \item{dataset}{ Dataset name,} + \item{name}{ Variable name,} + \item{type}{ Type of variable (one of 'character' or 'numeric'),} + \item{format}{ SAS format, } + \item{width}{ SAS format width, } + \item{label}{ Variable label, } + \item{nobs}{ Number of observations. } + } -\references{ - SAS Technical Support document TS-140: - \dQuote{The Record Layout of a Data Set in SAS Transport (XPORT) Format} - available as - \url{http://ftp.sas.com/techsup/download/technote/ts140.html}. +\details{ + The \code{lookup.xport} function is a simple wrapper for the + \code{\link[foreign]{lookup.xport}} function provided by the + \code{foreign} library. The wrapped adds the ability to handle URL's, + and returns an object of class \code{lookup.xport} for which + appropriate \code{print}, and \code{summary} functions are provide. } -\author{Saikat DebRoy} \seealso{ - \code{\link{read.xport}} + For complete documentation of \code{lookup.xport} see the manual page + for \code{\link[foreign]{lookup.xport}}. } \examples{ \dontrun{ -lookup.xport("transport") +## Get information on a local file +lookup.xport("xxx.xpt") } + +## Or read a copy of test2.xpt available on the web: +url <- 'http://biostat.mc.vanderbilt.edu/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt' +w <- lookup.xport(url) + +# display the infromation (calls 'print.lookup.xport') +w + +# names of data sets +names(w) + +# names of variables within data sets +w$Z$name + +# use summary +wS <- summary(w) +wS # same display + +# variable names within all data sets +wS$name + } \keyword{file} +\keyword{manip} \ No newline at end of file Modified: trunk/SASxport/man/read.xport.Rd =================================================================== --- trunk/SASxport/man/read.xport.Rd 2007-08-09 23:28:42 UTC (rev 1132) +++ trunk/SASxport/man/read.xport.Rd 2007-08-09 23:29:01 UTC (rev 1133) @@ -17,8 +17,8 @@ ) } \arguments{ - \item{file}{name of a file containing the SAS transport file. May be a - URL beginning with \code{http://}. + \item{file}{Character string specifying the name or URL of a SAS XPORT + file. } \item{force.integer}{Logical flag indicating whether integer-valued variables should be returned as integers (\code{TRUE}) or doubles Modified: trunk/SASxport/man/units.Rd =================================================================== --- trunk/SASxport/man/units.Rd 2007-08-09 23:28:42 UTC (rev 1132) +++ trunk/SASxport/man/units.Rd 2007-08-09 23:29:01 UTC (rev 1133) @@ -1,20 +1,28 @@ \name{units} + \alias{units} - \alias{units.default} - \alias{units<-} +\alias{units<-.default} \alias{label} +\alias{label.default} \alias{label<-} +\alias{label<-.default} \alias{formats} +\alias{formats.default} \alias{formats<-} +\alias{formats<-.default} \alias{iformat} +\alias{iformat.default} \alias{iformat<-} +\alias{iformat<-.default} + + \title{ -Set or Retreive the Label, Format, iFormat, or Units Attribute of a Vector +Set or Retreive the label, format, iformat, or units Attribute of a Vector } \description{ Sets or retrieves the \code{"label"}, \code{"format"}, @@ -24,41 +32,68 @@ available in Frank Harrell's \code{Hmisc} package. } \usage{ -units(x, ...) -\method{units}{default}(x, none='', \dots) +units(x, default) units(x) <- value + +label(x, default) +label(x) <- value + +formats(x, default) +formats(x) <- value + +iformat(x, default) +iformat(x) <- value + } \arguments{ \item{x}{any object} -\item{\dots}{ignored} -\item{value}{the units of the object, or ""} -\item{none}{value to which to set result if no appropriate attribute is - found} +\item{value}{new value for the \code{"label"}, \code{"format"}, + \code{"iformat"}, or \code{"units"} attribute of an object.} +\item{default}{value to return when no appropriate attribute is + found. The usual return value is NULL.} } \value{ -the units attribute of x, if any; otherwise, the \code{units} attribute of -the \code{tspar} attribute of \code{x} if any; otherwise the value \code{none} + the contents of the \code{"label"}, \code{"format"}, \code{"iformat"}, or + \code{"units"} attribute of x, if any; otherwise, the value provided by + \code{default}. } \author{Gregory R. Warnes \email{gr...@ra...} based on code from the \code{Hmisc} library by Frank E. Harrell, Jr.} \seealso{\code{\link{label}}} \examples{ + fail.time <- c(10,20) -units(fail.time) <- "Day" + +# set attributes +units(fail.time) <- 'Day' label(fail.time) <- 'Failure Time' -fail.time +formats(fail.time) <- 'Numeric2' +iformat(fail.time) <- 'Numeric2' + +# display individual attributes +units(fail.time) +label(fail.time) +formats(fail.time) +iformat(fail.time) + +# display all attributes +attributes(fail.time) + +# Example showing specification of default return value +a <- 70 +label(a, default="no label") + + \dontrun{ - # for a nice display library(Hmisc) describe(fail.time) - - f <- cph(Surv(fail.time, event) ~ xx) plot(xx,xx2,xlab=paste(label(xx),", ",units(xx),"s",sep="")) } + } \keyword{utilities} \keyword{interface} -% Converted by Sd2Rd version 1.21. + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-08-11 00:03:56
|
Revision: 1134 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1134&view=rev Author: warnes Date: 2007-08-10 17:03:52 -0700 (Fri, 10 Aug 2007) Log Message: ----------- Improve package description Modified Paths: -------------- trunk/SASxport/DESCRIPTION trunk/SASxport/man/SASxport-package.Rd Modified: trunk/SASxport/DESCRIPTION =================================================================== --- trunk/SASxport/DESCRIPTION 2007-08-09 23:29:01 UTC (rev 1133) +++ trunk/SASxport/DESCRIPTION 2007-08-11 00:03:52 UTC (rev 1134) @@ -6,14 +6,21 @@ Author: Gregory R. Warnes <gr...@ra...>, includes code from Frank E. Harrell, Jr.'s Hmisc package. Maintainer: Gregory R. Warnes <gr...@ra...> -Description: This package provides functions to read, list contents of, and - write SAS export files. This package was created by Random - Technologies LLC <http://random-technologies-llc.com> with funding - by Metrum Institute <http://metruminstitute.org>. +Description: This package provides functions for both reading, listing + contents of, and writing SAS xport format files. Reading + and writing of both individual and sets of data frames + are supported. Further, a mechanism has been provided + for customizing how variables of different data types are + stored. + . + This package was created by Random Technologies LLC + <http://random-technologies-llc.com> with funding by + Metrum Institute <http://metruminstitute.org>. . Technical support contracts and other services for for R, this package, and other packages are available from Random Technologies LLC <http://random-technologies-llc.com>. + License: GPL 2.0 or later Imports: methods, foreign, chron Modified: trunk/SASxport/man/SASxport-package.Rd =================================================================== --- trunk/SASxport/man/SASxport-package.Rd 2007-08-09 23:29:01 UTC (rev 1133) +++ trunk/SASxport/man/SASxport-package.Rd 2007-08-11 00:03:52 UTC (rev 1134) @@ -3,39 +3,67 @@ \alias{SASxport} \docType{package} \title{ -Read and write SAS export files + Read and write SAS export files } \description{ -This package provides functions to read, list contents of, -and write SAS export files. + This package provides functions to read, list contents of, and write + SAS export files. } \details{ -This package was created by Random -Technologies LLC <http://random-technologies-llc.com> with funding by -Metrum Institute <http://metruminstitute.org>. + The read.xport function for reading xport files augments the + functionality of the read.xport function provided in the "recommended" + package 'foreign' with additional features borrowed from Frank Harrell's + sasxport.get() in the 'Hmisc' package. Namely, variables are properly + coerced into the types specified by the format field. All standard + numeric and string formats are supported automatically, while + user-defined formats are supported when the used has included the format + data in the xport file via + + PROC FORMAT CNTLOUT=format; + + The write.xport function writes one or more data sets into a SAS xport + file. Standard R data types, including date and time objects + (e.g. Date, and POSIX.t) are stored with proper SAS format types. + Handling of object formatting is customizable by providing methods for + the function toSAS(). This is accomplished by writing a new method + for toSAS() for the object class of interest. The toSAS() method is + responsible for converting its argument to either a simple floating + point or character variable (the only basic types permitted by the + xport format) and adding the appropriate SAS format code in the + 'format' attribute. + + The write.xport() function, further, allows the user to override the + operating system type and SAS version information, as well as object + creation and modification times. + -Index: + This package was created by Random Technologies LLC + <http://random-technologies-llc.com> with funding by Metrum Institute + <http://metruminstitute.org>. + +} +\section{Index}{ \preformatted{ lookup.xport Lookup Information on a SAS XPORT Format Library read.xport Import SAS XPORT files -toSAS.default Convert R data object for storage in SAS xport - file -units Set or Retreive the label, format, iformat, or - units Attribute of a Vector +toSAS.default Convert R data object for storage in SAS + xport file +units Set or Retreive the label, format, + iformat, or units Attribute of a Vector write.xport Write data to a SAS XPORT file } } \author{ -Gregory R. Warnes <gr...@ra...>, includes -code from Frank E. Harrell, Jr.'s Hmisc package. + Gregory R. Warnes <gr...@ra...>, includes + code from Frank E. Harrell, Jr.'s Hmisc package. -Maintainer: Gregory R. Warnes <gr...@ra...> + Maintainer: Gregory R. Warnes <gr...@ra...> } -\section{support}{ -Technical support contracts and other services for for R, this package, -and other packages are available from Random Technologies LLC -<http://random-technologies-llc.com>. +\section{Support}{ + Technical support contracts and other services for for R, this package, + and other packages are available from Random Technologies LLC + <http://random-technologies-llc.com>. } \keyword{ package } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-08-12 03:22:53
|
Revision: 1138 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1138&view=rev Author: warnes Date: 2007-08-11 20:22:50 -0700 (Sat, 11 Aug 2007) Log Message: ----------- More updates Modified Paths: -------------- trunk/SASxport/DESCRIPTION trunk/SASxport/man/lookup.xport.Rd trunk/SASxport/src/cnxptiee.h trunk/SASxport/src/test_fields.c trunk/SASxport/src/writeSAS.h Modified: trunk/SASxport/DESCRIPTION =================================================================== --- trunk/SASxport/DESCRIPTION 2007-08-12 03:13:36 UTC (rev 1137) +++ trunk/SASxport/DESCRIPTION 2007-08-12 03:22:50 UTC (rev 1138) @@ -4,7 +4,10 @@ Version: 0.99.1 Date: 2007-07-28 Author: Gregory R. Warnes <gr...@ra...>, - includes code from Frank E. Harrell, Jr.'s Hmisc package. + includes code from Frank E. Harrell, Jr.'s Hmisc package, + and floating point conversion code from SAS techical support + document TS-140 "THE RECORD LAYOUT OF A DATA SET IN SAS" + TRANSPORT (XPORT) FORMAT. Maintainer: Gregory R. Warnes <gr...@ra...> Description: This package provides functions for both reading, listing contents of, and writing SAS xport format files. Reading @@ -20,7 +23,6 @@ Technical support contracts and other services for for R, this package, and other packages are available from Random Technologies LLC <http://random-technologies-llc.com>. - License: GPL 2.0 or later Imports: methods, foreign, chron Modified: trunk/SASxport/man/lookup.xport.Rd =================================================================== --- trunk/SASxport/man/lookup.xport.Rd 2007-08-12 03:13:36 UTC (rev 1137) +++ trunk/SASxport/man/lookup.xport.Rd 2007-08-12 03:22:50 UTC (rev 1138) @@ -10,12 +10,12 @@ \usage{ lookup.xport(file) \method{print}{lookup.xport}(x, ...) -\method{summary}{lookup.xport}(x, ...) +\method{summary}{lookup.xport}(object, ...) \method{print}{summary.lookup.xport}(x, ...) } \arguments{ \item{file}{Character string specifying the name or URL of a SAS XPORT file.} - \item{x}{Object to be printed or summarized} + \item{x, object}{Object to be printed or summarized} \item{...}{Optional arguments} } \value{ Modified: trunk/SASxport/src/cnxptiee.h =================================================================== --- trunk/SASxport/src/cnxptiee.h 2007-08-12 03:13:36 UTC (rev 1137) +++ trunk/SASxport/src/cnxptiee.h 2007-08-12 03:22:50 UTC (rev 1138) @@ -23,13 +23,13 @@ int get_native(); #endif -/* #ifdef BIG_ENDIAN */ -/* #define REVERSE(a,b) */ -/* #endif */ +#ifdef BIG_ENDIAN +#define REVERSE(a,b) +#endif -/* #ifdef LITTLE_ENDIAN */ -/* #define DEFINE_REVERSE */ -/* void REVERSE(); */ -/* #endif */ +#ifdef LITTLE_ENDIAN +#define DEFINE_REVERSE +void REVERSE(); +#endif #endif /* CNXPTIEE */ Modified: trunk/SASxport/src/test_fields.c =================================================================== --- trunk/SASxport/src/test_fields.c 2007-08-12 03:13:36 UTC (rev 1137) +++ trunk/SASxport/src/test_fields.c 2007-08-12 03:22:50 UTC (rev 1138) @@ -169,9 +169,5 @@ test_blankCopy(BIG); test_zeroCopy(BIG); - - - /* test reverse */ - test_reverse(); } Modified: trunk/SASxport/src/writeSAS.h =================================================================== --- trunk/SASxport/src/writeSAS.h 2007-08-12 03:13:36 UTC (rev 1137) +++ trunk/SASxport/src/writeSAS.h 2007-08-12 03:22:50 UTC (rev 1138) @@ -37,19 +37,6 @@ #define MISSING 0x2e000000 /* Standard SAS missing value: '.' */ /***** - REVERSE macro, used as a wrapper for the reverse() function to avoid - compiling/calling it on little-endian. - *****/ - -#ifdef BIG_ENDIAN -# define REVERSE(a,b) reverse( (u_char*) a, (size_t) b) -#elif defined(LITTLE_ENDIAN) -# define REVERSE(a,b) -#else -# define REVERSE(a,b) reverse( (u_char*) a, (size_t) b) -#endif - -/***** * Useful macro functions *****/ @@ -167,7 +154,4 @@ void doTest(); -void reverse( u_char *intp, size_t size); - - #endif /* FIELDS_H */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-08-21 18:13:15
|
Revision: 1156 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1156&view=rev Author: warnes Date: 2007-08-21 11:13:07 -0700 (Tue, 21 Aug 2007) Log Message: ----------- Commit previous updates Modified Paths: -------------- trunk/SASxport/TODO trunk/SASxport/man/lookup.xport.Rd trunk/SASxport/man/read.xport.Rd Modified: trunk/SASxport/TODO =================================================================== --- trunk/SASxport/TODO 2007-08-21 18:12:39 UTC (rev 1155) +++ trunk/SASxport/TODO 2007-08-21 18:13:07 UTC (rev 1156) @@ -1,17 +1,6 @@ -- Write replacements for SAS's REVERSE function, which corrects for - differences in endianness, and cnxptieee function, which is used to - convert from the IBM floating point representation to the IEEE - representation. - - Write test routines for very large files, particulary very large files with columns contiaining almost all missing values. - Test that created files are properly read by SAS, particulary when the SAS version and OS version are set to the default values I've provided. - -- Check function for 64 bit versions of R. I suspect that there may - be variable size issues for some int fields for write.xport(). - -- - Modified: trunk/SASxport/man/lookup.xport.Rd =================================================================== --- trunk/SASxport/man/lookup.xport.Rd 2007-08-21 18:12:39 UTC (rev 1155) +++ trunk/SASxport/man/lookup.xport.Rd 2007-08-21 18:13:07 UTC (rev 1156) @@ -50,6 +50,7 @@ } ## Or read a copy of test2.xpt available on the web: +\dontrun{ url <- 'http://biostat.mc.vanderbilt.edu/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt' w <- lookup.xport(url) @@ -68,7 +69,8 @@ # variable names within all data sets wS$name +} } \keyword{file} -\keyword{manip} \ No newline at end of file +\keyword{manip} Modified: trunk/SASxport/man/read.xport.Rd =================================================================== --- trunk/SASxport/man/read.xport.Rd 2007-08-21 18:12:39 UTC (rev 1155) +++ trunk/SASxport/man/read.xport.Rd 2007-08-21 18:13:07 UTC (rev 1156) @@ -157,6 +157,7 @@ SASxport:::assert(identical(w,w2)) } +\dontrun{ # Or read a copy of test2.xpt available on the web: url <- 'http://biostat.mc.vanderbilt.edu/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt' w <- read.xport(url) @@ -164,6 +165,7 @@ \dontshow{ ## For testing only SASxport:::assert(identical(w2,w)) } +} \dontrun{ ## The Hmisc library provides many useful functions for interacting with This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-08-22 18:11:59
|
Revision: 1159 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1159&view=rev Author: warnes Date: 2007-08-22 11:11:44 -0700 (Wed, 22 Aug 2007) Log Message: ----------- Modify read.xport to preserve case of SAS names by default, as well as updating the example code. Modified Paths: -------------- trunk/SASxport/R/read.xport.R trunk/SASxport/man/read.xport.Rd trunk/SASxport/tests/xport.Rout.save Modified: trunk/SASxport/R/read.xport.R =================================================================== --- trunk/SASxport/R/read.xport.R 2007-08-22 01:19:46 UTC (rev 1158) +++ trunk/SASxport/R/read.xport.R 2007-08-22 18:11:44 UTC (rev 1159) @@ -8,7 +8,7 @@ force.integer=TRUE, formats=NULL, name.chars=NULL, - names.tolower=TRUE, + names.tolower=FALSE, keep=NULL, drop=NULL, as.is=0.95, # Prevent factor conversion if 95% or more unique Modified: trunk/SASxport/man/read.xport.Rd =================================================================== --- trunk/SASxport/man/read.xport.Rd 2007-08-22 01:19:46 UTC (rev 1158) +++ trunk/SASxport/man/read.xport.Rd 2007-08-22 18:11:44 UTC (rev 1159) @@ -9,7 +9,7 @@ force.integer=TRUE, formats=NULL, name.chars=NULL, - names.tolower=TRUE, + names.tolower=FALSE, keep=NULL, drop=NULL, as.is=0.95, @@ -107,7 +107,7 @@ \code{\link[Hmisc]{describe}} } \examples{ -\dontrun{ + # ------- # SAS code to generate test dataset: # ------- @@ -149,44 +149,31 @@ # ------ # Read this dataset from a local file: +\dontrun{ w <- read.xport('test2.xpt') - -\dontshow{ -library(Hmisc) -w2 <- sasxport.get('test2.xpt') -SASxport:::assert(identical(w,w2)) } -\dontrun{ + # Or read a copy of test2.xpt available on the web: url <- 'http://biostat.mc.vanderbilt.edu/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt' w <- read.xport(url) -\dontshow{ ## For testing only -SASxport:::assert(identical(w2,w)) -} -} - \dontrun{ ## The Hmisc library provides many useful functions for interacting with ## data imported from SAS via read.xport() library(Hmisc) describe(w$test) # see labels, format names for dataset test +lapply(w, describe)# see descriptive stats in more detaiil for each variable -lapply(w, describe)# see descriptive stats for both datasets - contents(w$test) # another way to see variable attributes -lapply(w, contents)# show contents of both datasets +lapply(w, contents)# show contents of individual items in more detail options(digits=7) # compare the following matrix with PROC MEANS output t(sapply(w$z, function(x) c(Mean=mean(x),SD=sqrt(var(x)),Min=min(x),Max=max(x)))) - } } - -} \keyword{interface} \keyword{manip} Modified: trunk/SASxport/tests/xport.Rout.save =================================================================== --- trunk/SASxport/tests/xport.Rout.save 2007-08-22 01:19:46 UTC (rev 1158) +++ trunk/SASxport/tests/xport.Rout.save 2007-08-22 18:11:44 UTC (rev 1159) @@ -1,5 +1,5 @@ -R version 2.6.0 Under development (unstable) (2007-08-04 r42421) +R version 2.5.1 (2007-06-27) Copyright (C) 2007 The R Foundation for Statistical Computing ISBN 3-900051-07-0 @@ -45,14 +45,14 @@ > Alfalfa <- read.xport("Alfalfa.xpt") > > summary(Alfalfa) - pop sample rep seedwt harv1 + POP SAMPLE REP SEEDWT HARV1 MAX:20 Min. :0.0 Min. :1.00 Min. :35.00 Min. :120.6 min:20 1st Qu.:2.0 1st Qu.:1.75 1st Qu.:47.75 1st Qu.:148.3 Median :4.5 Median :2.50 Median :59.00 Median :165.8 Mean :4.5 Mean :2.50 Mean :56.08 Mean :163.0 3rd Qu.:7.0 3rd Qu.:3.25 3rd Qu.:62.25 3rd Qu.:176.4 Max. :9.0 Max. :4.00 Max. :75.00 Max. :193.4 - harv2 + HARV2 Min. :129.1 1st Qu.:150.6 Median :163.2 @@ -75,7 +75,7 @@ > testdata <- read.xport("test.xpt") > summary(testdata) - i k + I K Min. :1.00 Min. :1 1st Qu.:1.75 1st Qu.:1 Median :2.50 Median :2 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-08-22 19:21:15
|
Revision: 1160 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1160&view=rev Author: warnes Date: 2007-08-22 12:21:14 -0700 (Wed, 22 Aug 2007) Log Message: ----------- Update ChangeLog and NEWS files Added Paths: ----------- trunk/SASxport/ChangeLog trunk/SASxport/NEWS trunk/SASxport/inst/ChangeLog trunk/SASxport/inst/NEWS Added: trunk/SASxport/ChangeLog =================================================================== --- trunk/SASxport/ChangeLog (rev 0) +++ trunk/SASxport/ChangeLog 2007-08-22 19:21:14 UTC (rev 1160) @@ -0,0 +1 @@ +link inst/ChangeLog \ No newline at end of file Property changes on: trunk/SASxport/ChangeLog ___________________________________________________________________ Name: svn:special + * Added: trunk/SASxport/NEWS =================================================================== --- trunk/SASxport/NEWS (rev 0) +++ trunk/SASxport/NEWS 2007-08-22 19:21:14 UTC (rev 1160) @@ -0,0 +1 @@ +link inst/NEWS \ No newline at end of file Property changes on: trunk/SASxport/NEWS ___________________________________________________________________ Name: svn:special + * Added: trunk/SASxport/inst/ChangeLog =================================================================== --- trunk/SASxport/inst/ChangeLog (rev 0) +++ trunk/SASxport/inst/ChangeLog 2007-08-22 19:21:14 UTC (rev 1160) @@ -0,0 +1,222 @@ +2007-08-22 18:11 warnes + + * R/read.xport.R, man/read.xport.Rd, tests/xport.Rout.save: Modify + read.xport to preserve case of SAS names by default, as well as + updating the example code. + +2007-08-22 01:19 warnes + + * src/reverse.c: sprintf() was being used where printf() was + intended. + +2007-08-21 18:16 warnes + + * DESCRIPTION: Slight improvement to credits for BRL-CAD + +2007-08-21 18:13 warnes + + * TODO, man/lookup.xport.Rd, man/read.xport.Rd: Commit previous + updates + +2007-08-21 18:12 warnes + + * src/htond.c, src/ibm2ieee.c, src/ieee2ibm.c, src/init.c, + src/reverse.c, src/test_fields.c: Commit previous updates + +2007-08-15 07:02 warnes + + * DESCRIPTION, man/SASxport-package.Rd, src/cnxptiee.c, + src/cnxptiee.h, src/htond.c, src/init.c, src/reverse.c, + src/test_fields.c, src/writeSAS.c, src/writeSAS.h: Remove + dependency on SAS code + +2007-08-15 06:06 warnes + + * src/reverse.c: Fix reverse.c because we need to swap everything + to match Big-Endian, rather than Little-Endian. Also, dont' call + the macro. + +2007-08-15 06:04 warnes + + * src/reverse.c: Restore reverse.c + +2007-08-15 03:17 warnes + + * DESCRIPTION: Minor reformatting + +2007-08-15 03:14 warnes + + * DESCRIPTION, inst/doc/SAS_TS140.txt, inst/doc/index.html, + inst/doc/r2xpt.doc, man/SASxport-package.Rd, man/lookup.xport.Rd, + man/read.xport.Rd, man/toSAS.Rd, man/units.Rd, + man/write.xport.Rd: Make corrections for typos noted by Metrum + folks + +2007-08-12 03:22 warnes + + * DESCRIPTION, man/lookup.xport.Rd, src/cnxptiee.h, + src/test_fields.c, src/writeSAS.h: More updates + +2007-08-12 03:13 warnes + + * src/B8.h, src/IEEEtoIBM.c, src/MASKS.h, src/main.c, + src/reverse.c: Remove new stuff... use SAS's code instead + +2007-08-12 03:12 warnes + + * src/B8.h, src/IEEEtoIBM.c, src/MASKS.h, src/cnxptiee.h, + src/main.c, src/reverse.c, src/test_fields.c, src/writeSAS.h: 1st + attempt at rewriting cnxptiee.[ch] + +2007-08-11 23:48 warnes + + * R/read.xport.R: Explicitly check file header + +2007-08-11 00:03 warnes + + * DESCRIPTION, man/SASxport-package.Rd: Improve package description + +2007-08-09 23:29 warnes + + * DESCRIPTION, NAMESPACE, TODO, man/lookup.xport.Rd, + man/read.xport.Rd, man/units.Rd: More changes, esp to + lookup.xport() and friends + +2007-08-09 23:28 warnes + + * tests/Alfalfa_Test.Rout.save, tests/cars.Rout.save, + tests/xport.Rout.save: More changes, esp to lookup.xport() and + friends + +2007-08-09 23:28 warnes + + * R/AFirst.lib.s, R/all.is.numeric.R, R/in.opererator.R, + R/lookup.xport.R, R/read.xport.R, R/write.xport.R: More changes, + esp to lookup.xport() and friends + +2007-08-09 19:02 warnes + + * src/swap_bytes.h: Remove unused swap_bytes.h + +2007-08-09 19:02 warnes + + * man/SASxport-package.Rd: Add package description page + +2007-08-09 16:54 warnes + + * R/importConvertDateTime.R, R/makeNames.R, R/read.xport.R, + R/testDateTime.R: Add comment header indicating the source of + code from Hmisc + +2007-08-09 16:53 warnes + + * tests/testDates.Rout.save, tests/test_fields.Rout.save, + tests/xport.Rout.save, tests/xxx.Rout.save: Update saved output + of test scripts + +2007-08-08 18:54 warnes + + * DESCRIPTION, NAMESPACE: Updates + +2007-08-08 18:54 warnes + + * tests/Alfalfa_Test.R, tests/Alfalfa_Test.Rout.save, tests/cars.R, + tests/cars.Rout.save, tests/datetime.xpt, tests/testDates.R, + tests/test_fields.R, tests/test_fields.Rout.save, tests/xport.R, + tests/xxx.R, tests/xxx.Rout.save: Updates + +2007-08-08 18:54 warnes + + * src/SASxport.c, src/SASxport.h, src/foreign.h, src/init.c: + Updates + +2007-08-08 18:53 warnes + + * R/AFirst.lib.s, R/formats.R, R/iformat.R, + R/importConvertDateTime.R, R/label.R, R/lookup.xport.R, + R/makeNames.R, R/read.xport.R, R/testDateTime.R, R/units.R, + R/xport.R: Updates + +2007-08-08 18:53 warnes + + * man/assert.Rd, man/read.xport.Rd, man/units.Rd: Updates. + +2007-08-03 04:44 warnes + + * DESCRIPTION, NAMESPACE, R/scat.R, R/xport.R, R/zzz.R, + man/lookup.xport.Rd, man/read.xport.Rd, src/SASxport.c, + src/SASxport.h, src/cnxptiee.c, src/cnxptiee.h, src/foreign.h, + src/init.c, src/swap_bytes.h, src/test_fields.c, src/writeSAS.c, + src/writeSAS.h, tests/Alfalfa_Test.Rout.save, + tests/cars.Rout.save, tests/datetime.xpt, tests/test.xpt, + tests/testDates.Rout.save, tests/test_fields.Rout.save, + tests/xport.R, tests/xport.Rout.save, tests/xxx.Rout.save: Add + code from package foreign and gtools to make SASxport stand alone + +2007-08-03 01:46 warnes + + * R/.Rhistory: Remove stray .Rhistory file + +2007-08-03 01:45 warnes + + * DESCRIPTION: Acknowledge MetrumI support + +2007-08-03 01:45 warnes + + * NAMESPACE: Add "assert" function + +2007-08-03 01:44 warnes + + * R/assert.R, man/assert.Rd: Add "assert" function to avoid + dependenct on gtools. + +2007-08-03 01:29 warnes + + * man/toSAS.Rd, src/cnxptiee.c, src/writeSAS.c: Correct some typos. + +2007-08-03 00:40 warnes + + * DESCRIPTION: Drop version number to 0.99 until testing + integration and is complete + +2007-08-03 00:39 warnes + + * tests/test_fields.R: Add R test file to run c-level tests + +2007-08-03 00:36 warnes + + * src/SASxport.so: Remove .so from svn + +2007-08-03 00:35 warnes + + * NAMESPACE, R/fromSASDate.R, R/parseFormat.R, R/toSAS.R, + R/write.xport.R, R/xport.character.R, R/xport.file.header.R, + R/xport.member.header.R, R/xport.namestr.R, man/toSAS.Rd, + src/SASxport.so, src/writeSAS.c: More modifications. Should now + work for most R data types + +2007-08-03 00:35 warnes + + * tests/cars.R, tests/datetime.xpt, tests/testDates.R, tests/xxx.R: + Add more tests + +2007-07-29 01:15 warnes + + * tests/Alfalfa2.xpt, tests/cars.sas, tests/cars.xpt, + tests/xxx.sas, tests/xxx.xpt: Add SAS code to create xport data + files for testing + +2007-07-28 08:47 warnes + + * ., DESCRIPTION, NAMESPACE, R, R/.Rhistory, R/blanks.R, + R/rawToDisplay.R, R/write.xport.R, R/xport.NA.R, + R/xport.character.R, R/xport.dateFMT.R, R/xport.file.header.R, + R/xport.fill.R, R/xport.member.header.R, R/xport.namestr.R, + R/xport.namestr.header.R, R/xport.numeric.R, + R/xport.obs.header.R, R/zzz.R, inst, inst/doc, + inst/doc/SAS_TS140.txt, inst/doc/index.html, inst/doc/r2xpt.doc, + man, man/write.xport.Rd, src, src/SASxport.so, src/cnxptiee.c, + src/cnxptiee.h, src/test_fields.c, src/writeSAS.c, + src/writeSAS.h, tests, tests/Alfalfa.xpt, tests/Alfalfa2.xpt, + tests/Alfalfa_Test.R: Add SVNxport package + Added: trunk/SASxport/inst/NEWS =================================================================== --- trunk/SASxport/inst/NEWS (rev 0) +++ trunk/SASxport/inst/NEWS 2007-08-22 19:21:14 UTC (rev 1160) @@ -0,0 +1,40 @@ +Beta 3 - 2007-08-10 +------------------- + +New features: + +- read.xport's names.tolower argument now defaults to FALSE so that + variable (and data set) names are now left as uppercase. + +- Improved crediting of BRL-CAD source code + +Bug fixes: + +- Correct call to sprintf where printf was intended in src/ieee2ibm.c + +Other: + +- Augmented ieee2ibm code with corresponding ibm2ieee code for + completeness. + + +Beta 2 - 2007-08-10 +------------------- + +New Features: + +- Replaced IEEE to IBM translation code with GPL'ed version from BPL-CAD. + +Bug Fixes: + +- Changes to C code should correct the C99 usage errors + +- Correct documentation typos, including those reported by Tim. + + +Beta 1 - 2007-08-10 +------------------- + +Initial version of the SASxport package. + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-09-07 16:23:10
|
Revision: 1164 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1164&view=rev Author: warnes Date: 2007-09-07 09:23:10 -0700 (Fri, 07 Sep 2007) Log Message: ----------- Change argument name in write.xport from 'filename' to 'file' to match read.xport Modified Paths: -------------- trunk/SASxport/R/write.xport.R trunk/SASxport/man/read.xport.Rd trunk/SASxport/man/write.xport.Rd trunk/SASxport/tests/Alfalfa_Test.R trunk/SASxport/tests/cars.R trunk/SASxport/tests/testDates.R trunk/SASxport/tests/xxx.R Modified: trunk/SASxport/R/write.xport.R =================================================================== --- trunk/SASxport/R/write.xport.R 2007-09-07 16:21:08 UTC (rev 1163) +++ trunk/SASxport/R/write.xport.R 2007-09-07 16:23:10 UTC (rev 1164) @@ -1,5 +1,5 @@ write.xport <- function( ... , - filename="", + file="", verbose=FALSE, sasVer="7.00", osType, @@ -26,7 +26,7 @@ ## capture names of data frame, but don't clobber explicitly provided names mc <- match.call() - mc$filename <- NULL + mc$file <- NULL mc$verbose <- NULL mc$sasVer <- NULL mc$osType <- NULL @@ -41,11 +41,11 @@ names(dfList) <- dfNames scat("opening file ...") - if (is.character(filename)) - if (filename == "") + if (is.character(file)) + if (file == "") file <- stdout() else { - file <- file(description=filename, open="wb") + file <- file(description=file, open="wb") on.exit(close(file)) } scat("Done") @@ -175,8 +175,8 @@ } scat("Closing file ...") - if (is.character(filename)) - if (filename != "") + if (is.character(file)) + if (file != "") { close(file) on.exit() Modified: trunk/SASxport/man/read.xport.Rd =================================================================== --- trunk/SASxport/man/read.xport.Rd 2007-09-07 16:21:08 UTC (rev 1163) +++ trunk/SASxport/man/read.xport.Rd 2007-09-07 16:23:10 UTC (rev 1164) @@ -71,8 +71,6 @@ \details{ \itemize{ - \item variable names are converted to lower case - \item SAS date, time, and date/time variables are converted respectively to \code{Date}, POSIX, or \code{chron} objects Modified: trunk/SASxport/man/write.xport.Rd =================================================================== --- trunk/SASxport/man/write.xport.Rd 2007-09-07 16:21:08 UTC (rev 1163) +++ trunk/SASxport/man/write.xport.Rd 2007-09-07 16:23:10 UTC (rev 1164) @@ -6,12 +6,12 @@ library file. } \usage{ -write.xport(..., filename = "", verbose = FALSE, sasVer = "7.00", +write.xport(..., file = "", verbose = FALSE, sasVer = "7.00", osType, cDate = Sys.time()) } \arguments{ \item{\dots}{One or more data frames to be stored} - \item{filename}{Filename or connection object. Use "" to view the raw data} + \item{file}{File name or connection object. Use "" to view the raw data} \item{verbose}{Logical flag controlling whether status is reported during processing} \item{sasVer}{SAS version string} Modified: trunk/SASxport/tests/Alfalfa_Test.R =================================================================== --- trunk/SASxport/tests/Alfalfa_Test.R 2007-09-07 16:21:08 UTC (rev 1163) +++ trunk/SASxport/tests/Alfalfa_Test.R 2007-09-07 16:23:10 UTC (rev 1164) @@ -8,7 +8,7 @@ ## Write it out again, pretending to be the same OS, SAS version, and creation date write.xport(SPEC, - filename="Alfalfa2.xpt", + file="Alfalfa2.xpt", cDate=strptime("10DEC99:15:56:30", format="%d%b%y:%H:%M:%S"), osType="OSF1", sasVer="7.00" Modified: trunk/SASxport/tests/cars.R =================================================================== --- trunk/SASxport/tests/cars.R 2007-09-07 16:21:08 UTC (rev 1163) +++ trunk/SASxport/tests/cars.R 2007-09-07 16:23:10 UTC (rev 1164) @@ -10,7 +10,7 @@ summary(cars) write.xport(cars, - filename="cars2.xpt", + file="cars2.xpt", cDate=strptime("28JUL07: 20:59:49", format="%d%b%y:%H:%M:%S"), osType="SunOS", sasVer="9.1" Modified: trunk/SASxport/tests/testDates.R =================================================================== --- trunk/SASxport/tests/testDates.R 2007-09-07 16:21:08 UTC (rev 1163) +++ trunk/SASxport/tests/testDates.R 2007-09-07 16:23:10 UTC (rev 1164) @@ -14,7 +14,7 @@ print(temp) -write.xport( DATETIME=temp, filename="datetime.xpt") +write.xport( DATETIME=temp, file="datetime.xpt") temp2 <- read.xport(file="datetime.xpt", names.tolower=FALSE) print(temp2) Modified: trunk/SASxport/tests/xxx.R =================================================================== --- trunk/SASxport/tests/xxx.R 2007-09-07 16:21:08 UTC (rev 1163) +++ trunk/SASxport/tests/xxx.R 2007-09-07 16:23:10 UTC (rev 1164) @@ -11,7 +11,7 @@ # create a SAS XPORT file from our local data fram write.xport(abc, - filename="xxx2.xpt", + file="xxx2.xpt", cDate=strptime("28JUL07:21:08:06 ", format="%d%b%y:%H:%M:%S"), osType="SunOS", sasVer="9.1" @@ -25,7 +25,7 @@ # create a SAS XPORT file from the SAS data write.xport(abc=abc.SAS, - filename="xxx3.xpt", + file="xxx3.xpt", cDate=strptime("28JUL07:21:08:06 ", format="%d%b%y:%H:%M:%S"), osType="SunOS", sasVer="9.1" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-09-11 21:21:11
|
Revision: 1170 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1170&view=rev Author: warnes Date: 2007-09-11 14:21:09 -0700 (Tue, 11 Sep 2007) Log Message: ----------- Improve handling of list argument. Also check that names are proper and unique. Modified Paths: -------------- trunk/SASxport/R/write.xport.R trunk/SASxport/man/write.xport.Rd Modified: trunk/SASxport/R/write.xport.R =================================================================== --- trunk/SASxport/R/write.xport.R 2007-09-10 13:39:11 UTC (rev 1169) +++ trunk/SASxport/R/write.xport.R 2007-09-11 21:21:09 UTC (rev 1170) @@ -1,13 +1,21 @@ -write.xport <- function( ... , - file="", +write.xport <- function(..., + list=c(), + file = stop("'file' must be specified"), verbose=FALSE, sasVer="7.00", osType, cDate=Sys.time() ) { - dfList <- list(...) - dfNames <- names(dfList) + #if(missing(list)) + # { + list <- c(base::list(...), list) + dfNames <- names(list) + # } + #else + # { + # dfNames <- names(list) + # } if(missing(osType)) osType <- paste("R ", R.version$major, ".", R.version$minor, sep="") @@ -24,7 +32,8 @@ on.exit( options(DEBUG=oldDebug) ) - ## capture names of data frame, but don't clobber explicitly provided names + ## capture names of data frames from function call, but don't + ## clobber explicitly provided names mc <- match.call() mc$file <- NULL mc$verbose <- NULL @@ -38,8 +47,68 @@ dfNames <- mc } dfNames[dfNames==""] <- mc[dfNames==""] - names(dfList) <- dfNames + names(list) <- dfNames + +# ####### +# ## If no file argument is found, check if there is a single string +# ## argument. If so, assume that it is the destation filename +# if(missing(file)) +# { +# string.arg <- which(sapply(list,is.character)) +# if(length(string.arg)==1) +# { +# file <- list[[string.arg]] +# list[[string.arg]] <- NULL +# dfNames <- dfNames[-string.arg] +# } +# } +# ## +# ####### + + ####### + ## + scat("Ensure all objects to be stored are data.frames...\n") + not.df <- which(!sapply(list,is.data.frame)) + if(any(not.df)) + if(length(not.df)==1) + stop(paste("'", dfNames[not.df], "'"), + " is not a data.frame object.") + else + stop(paste("'", dfNames[not.df], "'", sep="", collapse=", "), + " are not data.frame objects.") + ## + ####### + + + ####### + ## + scat("Check length of object names...\n") + long.names <- which(nchar(dfNames)>8) + if(length(long.names)>0) + { + old.names <- dfNames[long.names] + new.names <- substr(old.names, 1, 8 ) + + warning("Truncating object names with more than 8 characters. ", + paste(long.names, + ":'", + old.names, + "' --> '", + new.names, + "'", + sep="", + collapse=", " )) + + dfNames[long.names] <- new.names + } + + scat("Ensure object names are unique...\n") + if(any(duplicated(dfNames))) + stop("object names are not unique: ", paste(1:length(dfNames),":'",dfNames,"'",sep="",collapse=", " )) + + + scat("opening file ...") if (is.character(file)) if (file == "") @@ -66,7 +135,7 @@ for(i in dfNames) { - df <- dfList[[i]] + df <- list[[i]] varNames <- colnames(df) offsetTable <- data.frame("name"=varNames, "len"=NA, "offset"=NA ) rownames(offsetTable) <- offsetTable[,"name"] @@ -83,7 +152,7 @@ lenIndex <- 0 varIndex <- 1 spaceUsed <- 0 - for(i in colnames(dfList[[i]]) ) + for(i in colnames(list[[i]]) ) { scat("", i , "...") var <- df[[i]] Modified: trunk/SASxport/man/write.xport.Rd =================================================================== --- trunk/SASxport/man/write.xport.Rd 2007-09-10 13:39:11 UTC (rev 1169) +++ trunk/SASxport/man/write.xport.Rd 2007-09-11 21:21:09 UTC (rev 1170) @@ -6,11 +6,17 @@ library file. } \usage{ -write.xport(..., file = "", verbose = FALSE, sasVer = "7.00", - osType, cDate = Sys.time()) +write.xport(..., + list=base::list(), + file = stop("'file' must be specified"), + verbose=FALSE, + sasVer="7.00", + osType, + cDate=Sys.time() ) } \arguments{ \item{\dots}{One or more data frames to be stored} + \item{list}{A list containing data frames to be stored.} \item{file}{File name or connection object. Use "" to view the raw data} \item{verbose}{Logical flag controlling whether status is reported during processing} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-09-11 21:22:33
|
Revision: 1171 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1171&view=rev Author: warnes Date: 2007-09-11 14:22:31 -0700 (Tue, 11 Sep 2007) Log Message: ----------- Correct error in handling 'verbose' argument, error when more than one dataset has the same name, and add 'as.list' argument to ensure return value is a list, even if there is only one dataset in the file Modified Paths: -------------- trunk/SASxport/R/read.xport.R trunk/SASxport/man/read.xport.Rd Modified: trunk/SASxport/R/read.xport.R =================================================================== --- trunk/SASxport/R/read.xport.R 2007-09-11 21:21:09 UTC (rev 1170) +++ trunk/SASxport/R/read.xport.R 2007-09-11 21:22:31 UTC (rev 1171) @@ -12,7 +12,8 @@ keep=NULL, drop=NULL, as.is=0.95, # Prevent factor conversion if 95% or more unique - verbose=FALSE + verbose=FALSE, + as.list=FALSE ) { sasdateform <- @@ -23,9 +24,9 @@ if(verbose) { - oldOptionsDebug <- options("DEBUG") + oldOptions <- options("DEBUG") options(DEBUG=TRUE) - on.exit(options(DEBUG=oldOptionsDebug)) + on.exit(options(oldOptions)) } if(length(grep('http://', file))>0 || length(grep('ftp://', file))>0 ) @@ -55,6 +56,14 @@ scat("Reading the data file...") ds <- foreign:::read.xport(file) + if(any(duplicated(names(dsinfo)))) # only true if file contains has more than one data set + { + warning("Duplicate data set names in file. Data set names have been made unique.") + names(dsinfo) <- make.unique(names(dsinfo)) + names(ds) <- make.unique(names(ds)) + } + + if( (length(keep)>0 || length(drop)>0) ) ds <- ds[whichds] @@ -124,12 +133,10 @@ else names.tolower <- function(x) x - if(nds > 1) - { - res <- vector('list', nds) - names(res) <- gsub('_','.',dsn) - } + res <- vector('list', nds) + names(res) <- gsub('_','.',dsn) + possiblyConvertChar <- (is.logical(as.is) && !as.is) || (is.numeric(as.is) && as.is > 0) j <- 0 @@ -197,14 +204,14 @@ } lz <- lab[nam[i]] - if(lz != '') { + if(!is.null(lz) && length(lz)>0 && !is.na(lz) && lz != '') { names(lz) <- NULL label(x) <- lz changed <- TRUE } fmt <- fmt[nam[i]]; - if( !is.null(fmt) && !is.na(fmt) && fmt > '') { + if( !is.null(fmt) && length(fmt)>0 && !is.na(fmt) && fmt > '') { names(fmt) <- NULL formats(x) <- fmt changed <- TRUE @@ -216,14 +223,13 @@ scat('.') - if(nds>1) - res[[j]] <- w + res[[j]] <- w } scat("Done") - - if(nds > 1) + if(nds > 1 || as.list) res - else w + else + w } Modified: trunk/SASxport/man/read.xport.Rd =================================================================== --- trunk/SASxport/man/read.xport.Rd 2007-09-11 21:21:09 UTC (rev 1170) +++ trunk/SASxport/man/read.xport.Rd 2007-09-11 21:22:31 UTC (rev 1171) @@ -13,7 +13,8 @@ keep=NULL, drop=NULL, as.is=0.95, - verbose=FALSE + verbose=FALSE, + as.list=FALSE ) } \arguments{ @@ -60,12 +61,14 @@ } \item{verbose}{Logical indicating whether progress should be printed during the data loading and conversion process.} + \item{as.list}{Logical indicating whether to return a list even if + the SAS xport file contains only only one dataset.} } \value{ - If there is more than one dataset in the transport file other than the - \code{PROC FORMAT} file, the result is a list of data frames - containing all the non-\code{PROC FORMAT} datasets. Otherwise the - result a single data frame. + If there the trasport file only contains one dataset (not counting any + \code{PROC FORMAT} datasets) and \code{as.list=FALSE}, the result is a + single data set. Otherwise the result is a list + containing all the non-\code{PROC FORMAT} datasets. } \details{ @@ -156,6 +159,14 @@ url <- 'http://biostat.mc.vanderbilt.edu/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt' w <- read.xport(url) + +# We can also get the dataset wrapped in a list +w <- read.xport(url, as.list=TRUE) + +\dontshow{ +assert( is.data.frame(w)==FALSE && is.list(w)==TRUE ) +} + \dontrun{ ## The Hmisc library provides many useful functions for interacting with ## data imported from SAS via read.xport() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-09-12 22:25:09
|
Revision: 1175 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1175&view=rev Author: warnes Date: 2007-09-12 15:25:07 -0700 (Wed, 12 Sep 2007) Log Message: ----------- Remove units() and units<-() functions since they arene't ever used. Added Paths: ----------- trunk/SASxport/man/label.Rd Removed Paths: ------------- trunk/SASxport/R/units.R trunk/SASxport/man/units.Rd Deleted: trunk/SASxport/R/units.R =================================================================== --- trunk/SASxport/R/units.R 2007-09-12 22:24:11 UTC (rev 1174) +++ trunk/SASxport/R/units.R 2007-09-12 22:25:07 UTC (rev 1175) @@ -1,20 +0,0 @@ -units <- function(x, default) - UseMethod("units") - -units.default <- function(x, default=NULL) -{ - lab <- attr(x,"units") - if(is.null(lab)) - default - else - lab -} - -"units<-" <- function(x, value) - UseMethod("units<-") - -"units<-.default" <- function(x, value) -{ - attr(x,'units') <- value - x -} Copied: trunk/SASxport/man/label.Rd (from rev 1174, trunk/SASxport/man/units.Rd) =================================================================== --- trunk/SASxport/man/label.Rd (rev 0) +++ trunk/SASxport/man/label.Rd 2007-09-12 22:25:07 UTC (rev 1175) @@ -0,0 +1,90 @@ +\name{label} + +\alias{label} +\alias{label.default} +\alias{label<-} +\alias{label<-.default} + +\alias{formats} +\alias{formats.default} +\alias{formats<-} +\alias{formats<-.default} + +\alias{iformat} +\alias{iformat.default} +\alias{iformat<-} +\alias{iformat<-.default} + + +\title{ +Set or Retreive the 'label', 'format', or 'iformat' Attribute of a Vector +} +\description{ + Sets or retrieves the \code{"label"}, \code{"format"}, or + \code{"iformat"} attribute of an object. + + More comprehensive support for object labels, and formats, are + available in Frank Harrell's \code{Hmisc} package. +} +\usage{ +label(x, default) +label(x) <- value + +formats(x, default) +formats(x) <- value + +iformat(x, default) +iformat(x) <- value + +} +\arguments{ +\item{x}{any object} +\item{value}{new value for the \code{"label"}, \code{"format"}, or + \code{"iformat"} attribute of an object.} +\item{default}{value to return when no appropriate attribute is + found. The usual return value is NULL.} +} +\value{ + the contents of the \code{"label"}, \code{"format"}, or + \code{"iformat"} attribute of x, if any; otherwise, the value provided + by \code{default}. +} +\author{Gregory R. Warnes \email{gr...@ra...} based + on code from the \code{Hmisc} library by Frank E. Harrell, Jr.} +%\seealso{ +%} +\examples{ + +fail.time <- c(10,20) + +# set attributes +label(fail.time) <- 'Failure Time' +formats(fail.time) <- 'Numeric2' +iformat(fail.time) <- 'Numeric2' + +# display individual attributes +label(fail.time) +formats(fail.time) +iformat(fail.time) + +# display all attributes +attributes(fail.time) + +# Example showing specification of default return value +a <- 70 +label(a, default="no label") + + +\dontrun{ +# for a nice display +library(Hmisc) +describe(fail.time) + +f <- cph(Surv(fail.time, event) ~ xx) +plot(xx,xx2,xlab=label(xx),"s",sep="")) +} + +} +\keyword{utilities} +\keyword{interface} + Deleted: trunk/SASxport/man/units.Rd =================================================================== --- trunk/SASxport/man/units.Rd 2007-09-12 22:24:11 UTC (rev 1174) +++ trunk/SASxport/man/units.Rd 2007-09-12 22:25:07 UTC (rev 1175) @@ -1,90 +0,0 @@ -\name{label} - -\alias{label} -\alias{label.default} -\alias{label<-} -\alias{label<-.default} - -\alias{formats} -\alias{formats.default} -\alias{formats<-} -\alias{formats<-.default} - -\alias{iformat} -\alias{iformat.default} -\alias{iformat<-} -\alias{iformat<-.default} - - -\title{ -Set or Retreive the 'label', 'format', or 'iformat' Attribute of a Vector -} -\description{ - Sets or retrieves the \code{"label"}, \code{"format"}, or - \code{"iformat"} attribute of an object. - - More comprehensive support for object labels, and formats, are - available in Frank Harrell's \code{Hmisc} package. -} -\usage{ -label(x, default) -label(x) <- value - -formats(x, default) -formats(x) <- value - -iformat(x, default) -iformat(x) <- value - -} -\arguments{ -\item{x}{any object} -\item{value}{new value for the \code{"label"}, \code{"format"}, or - \code{"iformat"} attribute of an object.} -\item{default}{value to return when no appropriate attribute is - found. The usual return value is NULL.} -} -\value{ - the contents of the \code{"label"}, \code{"format"}, or - \code{"iformat"} attribute of x, if any; otherwise, the value provided - by \code{default}. -} -\author{Gregory R. Warnes \email{gr...@ra...} based - on code from the \code{Hmisc} library by Frank E. Harrell, Jr.} -%\seealso{ -%} -\examples{ - -fail.time <- c(10,20) - -# set attributes -label(fail.time) <- 'Failure Time' -formats(fail.time) <- 'Numeric2' -iformat(fail.time) <- 'Numeric2' - -# display individual attributes -label(fail.time) -formats(fail.time) -iformat(fail.time) - -# display all attributes -attributes(fail.time) - -# Example showing specification of default return value -a <- 70 -label(a, default="no label") - - -\dontrun{ -# for a nice display -library(Hmisc) -describe(fail.time) - -f <- cph(Surv(fail.time, event) ~ xx) -plot(xx,xx2,xlab=label(xx),"s",sep="")) -} - -} -\keyword{utilities} -\keyword{interface} - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-09-14 15:35:45
|
Revision: 1183 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1183&view=rev Author: warnes Date: 2007-09-14 08:35:40 -0700 (Fri, 14 Sep 2007) Log Message: ----------- Add option to read.xport() that permits inclusion of PROC CONTENTS format information in the returned list Modified Paths: -------------- trunk/SASxport/R/read.xport.R trunk/SASxport/inst/ChangeLog trunk/SASxport/man/lookup.xport.Rd trunk/SASxport/man/read.xport.Rd trunk/SASxport/tests/TestUnnamedComponents.Rout.save Added Paths: ----------- trunk/SASxport/R/process.formats.R trunk/SASxport/data/ trunk/SASxport/data/Alfalfa.R trunk/SASxport/data/Alfalfa.xpt trunk/SASxport/man/Alfalfa.Rd Added: trunk/SASxport/R/process.formats.R =================================================================== --- trunk/SASxport/R/process.formats.R (rev 0) +++ trunk/SASxport/R/process.formats.R 2007-09-14 15:35:40 UTC (rev 1183) @@ -0,0 +1,38 @@ +## Transform SAS 'PROC CONTENTS' dataset into a form useful for +## converting raw SAS objects to/from the appropriate R objects. + +process.formats <- function(finfo) + { + if(is.null(finfo)) return( list() ) + ## Remove leading $ from char format names + ## fmtname <- sub('^\\$','',as.character(finfo$FMTNAME)) + fmtname <- as.character(finfo$FMTNAME) + finfo <- split(finfo[c('START','END','LABEL')], fmtname) + finfo <- lapply(finfo, + function(f) + { + rb <- function(a) + { # remove leading + trailing blanks + a <- sub('[[:space:]]+$', '', as.character(a)) + sub('^[[:space:]]+', '', a) + } + + st <- rb(f$START) + en <- rb(f$END) + lab <- rb(f$LABEL) + ##j <- is.na(st) | is.na(en) + ## st %in% c('','.','NA') | en %in% c('','.','NA') + j <- is.na(st) | is.na(en) | st == '' | en == '' + if(any(j)) { + warning('NA in code in FORMAT definition; removed') + st <- st[!j]; en <- en[!j]; lab <- lab[!j] + } + + if(!all(st==en)) + stop("Format ranges are not handled.") + + list(value = all.is.numeric(st, 'vector'), + label = lab) + }) + finfo + } Modified: trunk/SASxport/R/read.xport.R =================================================================== --- trunk/SASxport/R/read.xport.R 2007-09-14 14:37:48 UTC (rev 1182) +++ trunk/SASxport/R/read.xport.R 2007-09-14 15:35:40 UTC (rev 1183) @@ -13,7 +13,8 @@ drop=NULL, as.is=0.95, # Prevent factor conversion if 95% or more unique verbose=FALSE, - as.list=FALSE + as.list=FALSE, + include.formats=FALSE ) { sasdateform <- @@ -84,40 +85,9 @@ finfo <- NULL if(length(formats) || length(fds)) { if(length(formats)) - finfo <- formats + finfo <- process.formats(formats) else - finfo <- ds[[fds]] - - ## Remove leading $ from char format names - ## fmtname <- sub('^\\$','',as.character(finfo$FMTNAME)) - fmtname <- as.character(finfo$FMTNAME) - finfo <- split(finfo[c('START','END','LABEL')], fmtname) - finfo <- lapply(finfo, - function(f) - { - rb <- function(a) - { # remove leading + trailing blanks - a <- sub('[[:space:]]+$', '', as.character(a)) - sub('^[[:space:]]+', '', a) - } - - st <- rb(f$START) - en <- rb(f$END) - lab <- rb(f$LABEL) - ##j <- is.na(st) | is.na(en) - ## st %in% c('','.','NA') | en %in% c('','.','NA') - j <- is.na(st) | is.na(en) | st == '' | en == '' - if(any(j)) { - warning('NA in code in FORMAT definition; removed') - st <- st[!j]; en <- en[!j]; lab <- lab[!j] - } - - if(!all(st==en)) - return(NULL) - - list(value = all.is.numeric(st, 'vector'), - label = lab) - }) + finfo <- process.formats(ds[[fds]]) } ## Number of non-format datasets @@ -165,7 +135,8 @@ for(i in 1:length(w)) { changed <- FALSE x <- w[[i]] - fi <- fmt[nam[i]]; names(fi) <- NULL + fi <- fmt[nam[i]]; + names(fi) <- NULL if(fi != '' && length(finfo) && (fi %in% names(finfo))) { f <- finfo[[fi]] if(length(f)) { ## may be NULL because had a range in format @@ -227,6 +198,13 @@ } scat("Done") + + if(include.formats) + { + nds <- nds+1 + res$"FORMATS" <- ds[[fds]] + } + if(nds > 1 || as.list) res Added: trunk/SASxport/data/Alfalfa.R =================================================================== --- trunk/SASxport/data/Alfalfa.R (rev 0) +++ trunk/SASxport/data/Alfalfa.R 2007-09-14 15:35:40 UTC (rev 1183) @@ -0,0 +1,3 @@ +library(SASxport) + +Alfalfa <- read.xport("Alfalfa.xpt") Added: trunk/SASxport/data/Alfalfa.xpt =================================================================== (Binary files differ) Property changes on: trunk/SASxport/data/Alfalfa.xpt ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/SASxport/inst/ChangeLog =================================================================== --- trunk/SASxport/inst/ChangeLog 2007-09-14 14:37:48 UTC (rev 1182) +++ trunk/SASxport/inst/ChangeLog 2007-09-14 15:35:40 UTC (rev 1183) @@ -1,3 +1,94 @@ +2007-09-13 01:55 warnes + + * tests/TestUnnamedComponents.Rout.save: Update test output to + match recent changes. + +2007-09-13 01:19 warnes + + * R/write.xport.R: Add checking and handling for unnamed data + frames or variables + +2007-09-13 01:14 warnes + + * tests/Alfalfa_Test.Rout.save, tests/TestUnnamedComponents.R, + tests/TestUnnamedComponents.Rout.save, tests/Theoph.Rout.save, + tests/cars.Rout.save, tests/testDates.Rout.save, + tests/test_fields.Rout.save, tests/xport.Rout.save, + tests/xxx.Rout.save: Update tests now that 'units' and 'units<-' + functions no longer are included + +2007-09-12 22:27 warnes + + * NAMESPACE: Remove units() and units<-() functions since they + arene't ever used. + +2007-09-12 22:25 warnes + + * R/units.R, man/label.Rd, man/units.Rd: Remove units() and + units<-() functions since they arene't ever used. + +2007-09-12 22:24 warnes + + * man/units.Rd: Remove units from manual page + +2007-09-11 23:08 warnes + + * man/read.xport.Rd: Add assertion to test that read.xport(.., + as.list=TRUE) works properly + +2007-09-11 23:05 warnes + + * R/write.xport.R: Forgot to save buffer before svn commit. + +2007-09-11 21:22 warnes + + * R/read.xport.R, man/read.xport.Rd: Correct error in handling + 'verbose' argument, error when more than one dataset has the same + name, and add 'as.list' argument to ensure return value is a + list, even if there is only one dataset in the file + +2007-09-11 21:21 warnes + + * R/write.xport.R, man/write.xport.Rd: Improve handling of list + argument. Also check that names are proper and unique. + +2007-09-07 16:47 warnes + + * tests/Theoph.R, tests/Theoph.Rout.save: Add round-trip test for + Theoph data set + +2007-09-07 16:32 warnes + + * tests/Alfalfa_Test.Rout.save, tests/cars.Rout.save, + tests/testDates.Rout.save, tests/xxx.Rout.save: Change argument + name in write.xport from 'filename' to 'file' to match read.xport + +2007-09-07 16:25 warnes + + * man/write.xport.Rd: Change argument name in write.xport from + 'filename' to 'file' to match read.xport + +2007-09-07 16:23 warnes + + * R/write.xport.R, man/read.xport.Rd, man/write.xport.Rd, + tests/Alfalfa_Test.R, tests/cars.R, tests/testDates.R, + tests/xxx.R: Change argument name in write.xport from 'filename' + to 'file' to match read.xport + +2007-09-07 16:21 warnes + + * DESCRIPTION: Fix typo + +2007-08-29 02:24 warnes + + * DESCRIPTION: Update Version to 1.0, depend on current version of + foreign + +2007-08-22 19:21 warnes + + * ChangeLog, NEWS, inst/ChangeLog, inst/NEWS: Update ChangeLog and + NEWS files + 2007-08-22 18:11 warnes * R/read.xport.R, man/read.xport.Rd, tests/xport.Rout.save: Modify Added: trunk/SASxport/man/Alfalfa.Rd =================================================================== --- trunk/SASxport/man/Alfalfa.Rd (rev 0) +++ trunk/SASxport/man/Alfalfa.Rd 2007-09-14 15:35:40 UTC (rev 1183) @@ -0,0 +1,54 @@ +\name{Alfalfa} +\alias{Alfalfa} +\docType{data} +\title{ Example SAS data set } +\description{ + This data set exists to provide an example file for lookup.xport() and + read.xport() +} +\usage{data(Alfalfa)} +\format{ + A data frame with 40 observations on the following 6 variables. + \describe{ + \item{\code{POP}}{Population, a factor with levels \code{MAX} amd \code{min}} + \item{\code{SAMPLE}}{Sample ID (0:5)} + \item{\code{REP}}{Replicate (always 1)} + \item{\code{SEEDWT}}{Sed weight} + \item{\code{HARV1}}{Harvest 1 volume} + \item{\code{HARV2}}{Harvest 2 volume} + } +} +\details{ + Population "MAX" has slightly higher harvest volumes (\code{HARV1} and + \code{HARV2}) than population "min". (Surprise! Shock! Awe!) + } +\source{ + The 'Alfalfa.xpt' file was obtained from the R 'foreign' package. +} +\examples{ +data(Alfalfa) + +# go were the data is... +here <- getwd() +setwd(file.path(.path.package("SASxport"),"data")) + +# Description of the file contents +lookup.xport("Alfalfa.xpt") + +# Load the file contents +Alfalfa <- read.xport("Alfalfa.xpt") +head(Alfalfa) + +# return home +setwd(here) + +# Just for fun, plot the data +par(mfrow=c(1,2)) +plot( HARV1 ~ POP, data=Alfalfa) +plot( HARV2 ~ POP, data=Alfalfa) + + + + +} +\keyword{datasets} Modified: trunk/SASxport/man/lookup.xport.Rd =================================================================== --- trunk/SASxport/man/lookup.xport.Rd 2007-09-14 14:37:48 UTC (rev 1182) +++ trunk/SASxport/man/lookup.xport.Rd 2007-09-14 15:35:40 UTC (rev 1183) @@ -44,11 +44,13 @@ for \code{\link[foreign]{lookup.xport}}. } \examples{ -\dontrun{ +\dontshow{ +setwd(file.path(.path.package("SASxport"),"data")) +} ## Get information on a local file -lookup.xport("xxx.xpt") -} +lookup.xport("Alfalfa.xpt") + ## Or read a copy of test2.xpt available on the web: \dontrun{ url <- 'http://biostat.mc.vanderbilt.edu/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt' Modified: trunk/SASxport/man/read.xport.Rd =================================================================== --- trunk/SASxport/man/read.xport.Rd 2007-09-14 14:37:48 UTC (rev 1182) +++ trunk/SASxport/man/read.xport.Rd 2007-09-14 15:35:40 UTC (rev 1183) @@ -14,7 +14,8 @@ drop=NULL, as.is=0.95, verbose=FALSE, - as.list=FALSE + as.list=FALSE, + include.formats=FALSE ) } \arguments{ @@ -63,14 +64,18 @@ during the data loading and conversion process.} \item{as.list}{Logical indicating whether to return a list even if the SAS xport file contains only only one dataset.} + \item{include.formats}{Logical indicating whether to include SAS + format information (if present) in the returned list} } \value{ - If there the trasport file only contains one dataset (not counting any - \code{PROC FORMAT} datasets) and \code{as.list=FALSE}, the result is a - single data set. Otherwise the result is a list - containing all the non-\code{PROC FORMAT} datasets. + If only a single dataset is present (after removing \code{PROC FORMAT} + data when \code{include.formats=FALSE}), the return value is a single + dataframe object. Otherwise the return is a list of dataframe objects. + + Note that if \code{include.formats=TRUE}, the returned list will + contain a dataframe named "FORMATS" containing any available 'PROC FORMAT' + information. } - \details{ \itemize{ @@ -163,6 +168,9 @@ # We can also get the dataset wrapped in a list w <- read.xport(url, as.list=TRUE) +# And we can ask for the format information to be included as well. +w <- read.xport(url, as.list=TRUE, include.formats=TRUE) + \dontshow{ SASxport:::assert( is.data.frame(w)==FALSE && is.list(w)==TRUE ) } Modified: trunk/SASxport/tests/TestUnnamedComponents.Rout.save =================================================================== --- trunk/SASxport/tests/TestUnnamedComponents.Rout.save 2007-09-14 14:37:48 UTC (rev 1182) +++ trunk/SASxport/tests/TestUnnamedComponents.Rout.save 2007-09-14 15:35:40 UTC (rev 1183) @@ -74,6 +74,9 @@ rd.xpr> # We can also get the dataset wrapped in a list rd.xpr> w <- read.xport(url, as.list=TRUE) +rd.xpr> # And we can ask for the format information to be included as well. +rd.xpr> w <- read.xport(url, as.list=TRUE, include.formats=TRUE) + rd.xpr> ## Don't show: rd.xpr> SASxport:::assert( is.data.frame(w)==FALSE && is.list(w)==TRUE ) > write.xport(w$test,file="a.xpt") @@ -228,6 +231,30 @@ Z.X7 Z X7 numeric 8 100 Z.X8 Z X8 numeric 8 100 +Variables in data set `FORMATS': + dataset name type format width label nobs +FORMATS.FMTNAME FORMATS FMTNAME character 8 3 +FORMATS.START FORMATS START character 16 3 +FORMATS.END FORMATS END character 16 3 +FORMATS.LABEL FORMATS LABEL character 8 3 +FORMATS.MIN FORMATS MIN numeric 8 3 +FORMATS.MAX FORMATS MAX numeric 8 3 +FORMATS.DEFAULT FORMATS DEFAULT numeric 8 3 +FORMATS.LENGTH FORMATS LENGTH numeric 8 3 +FORMATS.FUZZ FORMATS FUZZ numeric 8 3 +FORMATS.PREFIX FORMATS PREFIX character 8 3 +FORMATS.MULT FORMATS MULT numeric 8 3 +FORMATS.FILL FORMATS FILL character 8 3 +FORMATS.NOEDIT FORMATS NOEDIT numeric 8 3 +FORMATS.TYPE FORMATS TYPE character 8 3 +FORMATS.SEXCL FORMATS SEXCL character 8 3 +FORMATS.EEXCL FORMATS EEXCL character 8 3 +FORMATS.HLO FORMATS HLO character 8 3 +FORMATS.DECSEP FORMATS DECSEP character 8 3 +FORMATS.DIG3SEP FORMATS DIG3SEP character 8 3 +FORMATS.DATATYPE FORMATS DATATYPE character 8 3 +FORMATS.LANGUAGE FORMATS LANGUAGE character 8 3 + > > names(w) <- NULL > write.xport(w[[1]],w[[2]],file="a.xpt") @@ -284,6 +311,30 @@ NONAME.1.X7 NONAME.1 X7 numeric 8 100 NONAME.1.X8 NONAME.1 X8 numeric 8 100 +Variables in data set `NONAME.2': + dataset name type format width label nobs +NONAME.2.FMTNAME NONAME.2 FMTNAME character 8 3 +NONAME.2.START NONAME.2 START character 16 3 +NONAME.2.END NONAME.2 END character 16 3 +NONAME.2.LABEL NONAME.2 LABEL character 8 3 +NONAME.2.MIN NONAME.2 MIN numeric 8 3 +NONAME.2.MAX NONAME.2 MAX numeric 8 3 +NONAME.2.DEFAULT NONAME.2 DEFAULT numeric 8 3 +NONAME.2.LENGTH NONAME.2 LENGTH numeric 8 3 +NONAME.2.FUZZ NONAME.2 FUZZ numeric 8 3 +NONAME.2.PREFIX NONAME.2 PREFIX character 8 3 +NONAME.2.MULT NONAME.2 MULT numeric 8 3 +NONAME.2.FILL NONAME.2 FILL character 8 3 +NONAME.2.NOEDIT NONAME.2 NOEDIT numeric 8 3 +NONAME.2.TYPE NONAME.2 TYPE character 8 3 +NONAME.2.SEXCL NONAME.2 SEXCL character 8 3 +NONAME.2.EEXCL NONAME.2 EEXCL character 8 3 +NONAME.2.HLO NONAME.2 HLO character 8 3 +NONAME.2.DECSEP NONAME.2 DECSEP character 8 3 +NONAME.2.DIG3SEP NONAME.2 DIG3SEP character 8 3 +NONAME.2.DATATYPE NONAME.2 DATATYPE character 8 3 +NONAME.2.LANGUAGE NONAME.2 LANGUAGE character 8 3 + > > ### Check that we catch invalid parameters > failure <- try( write.xport(5,"a.xpt") ) @@ -352,6 +403,9 @@ rd.xpr> # We can also get the dataset wrapped in a list rd.xpr> w <- read.xport(url, as.list=TRUE) +rd.xpr> # And we can ask for the format information to be included as well. +rd.xpr> w <- read.xport(url, as.list=TRUE, include.formats=TRUE) + rd.xpr> ## Don't show: rd.xpr> SASxport:::assert( is.data.frame(w)==FALSE && is.list(w)==TRUE ) > write.xport(list=base::list(w$test,w$z),file="a.xpt") @@ -437,6 +491,9 @@ rd.xpr> # We can also get the dataset wrapped in a list rd.xpr> w <- read.xport(url, as.list=TRUE) +rd.xpr> # And we can ask for the format information to be included as well. +rd.xpr> w <- read.xport(url, as.list=TRUE, include.formats=TRUE) + rd.xpr> ## Don't show: rd.xpr> SASxport:::assert( is.data.frame(w)==FALSE && is.list(w)==TRUE ) > names(w) <- NULL @@ -466,6 +523,30 @@ NONAME.1.X7 NONAME.1 X7 numeric 8 100 NONAME.1.X8 NONAME.1 X8 numeric 8 100 +Variables in data set `NONAME.2': + dataset name type format width label nobs +NONAME.2.FMTNAME NONAME.2 FMTNAME character 8 3 +NONAME.2.START NONAME.2 START character 16 3 +NONAME.2.END NONAME.2 END character 16 3 +NONAME.2.LABEL NONAME.2 LABEL character 8 3 +NONAME.2.MIN NONAME.2 MIN numeric 8 3 +NONAME.2.MAX NONAME.2 MAX numeric 8 3 +NONAME.2.DEFAULT NONAME.2 DEFAULT numeric 8 3 +NONAME.2.LENGTH NONAME.2 LENGTH numeric 8 3 +NONAME.2.FUZZ NONAME.2 FUZZ numeric 8 3 +NONAME.2.PREFIX NONAME.2 PREFIX character 8 3 +NONAME.2.MULT NONAME.2 MULT numeric 8 3 +NONAME.2.FILL NONAME.2 FILL character 8 3 +NONAME.2.NOEDIT NONAME.2 NOEDIT numeric 8 3 +NONAME.2.TYPE NONAME.2 TYPE character 8 3 +NONAME.2.SEXCL NONAME.2 SEXCL character 8 3 +NONAME.2.EEXCL NONAME.2 EEXCL character 8 3 +NONAME.2.HLO NONAME.2 HLO character 8 3 +NONAME.2.DECSEP NONAME.2 DECSEP character 8 3 +NONAME.2.DIG3SEP NONAME.2 DIG3SEP character 8 3 +NONAME.2.DATATYPE NONAME.2 DATATYPE character 8 3 +NONAME.2.LANGUAGE NONAME.2 LANGUAGE character 8 3 + > > # remove variable names > example(read.xport) @@ -523,6 +604,9 @@ rd.xpr> # We can also get the dataset wrapped in a list rd.xpr> w <- read.xport(url, as.list=TRUE) +rd.xpr> # And we can ask for the format information to be included as well. +rd.xpr> w <- read.xport(url, as.list=TRUE, include.formats=TRUE) + rd.xpr> ## Don't show: rd.xpr> SASxport:::assert( is.data.frame(w)==FALSE && is.list(w)==TRUE ) > colnames(w[[2]]) <- c() @@ -553,4 +637,28 @@ Z.NONAME_3 Z NONAME_3 numeric 8 100 Z.NONAME_4 Z NONAME_4 numeric 8 100 +Variables in data set `FORMATS': + dataset name type format width label nobs +FORMATS.FMTNAME FORMATS FMTNAME character 8 3 +FORMATS.START FORMATS START character 16 3 +FORMATS.END FORMATS END character 16 3 +FORMATS.LABEL FORMATS LABEL character 8 3 +FORMATS.MIN FORMATS MIN numeric 8 3 +FORMATS.MAX FORMATS MAX numeric 8 3 +FORMATS.DEFAULT FORMATS DEFAULT numeric 8 3 +FORMATS.LENGTH FORMATS LENGTH numeric 8 3 +FORMATS.FUZZ FORMATS FUZZ numeric 8 3 +FORMATS.PREFIX FORMATS PREFIX character 8 3 +FORMATS.MULT FORMATS MULT numeric 8 3 +FORMATS.FILL FORMATS FILL character 8 3 +FORMATS.NOEDIT FORMATS NOEDIT numeric 8 3 +FORMATS.TYPE FORMATS TYPE character 8 3 +FORMATS.SEXCL FORMATS SEXCL character 8 3 +FORMATS.EEXCL FORMATS EEXCL character 8 3 +FORMATS.HLO FORMATS HLO character 8 3 +FORMATS.DECSEP FORMATS DECSEP character 8 3 +FORMATS.DIG3SEP FORMATS DIG3SEP character 8 3 +FORMATS.DATATYPE FORMATS DATATYPE character 8 3 +FORMATS.LANGUAGE FORMATS LANGUAGE character 8 3 + > This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-09-15 06:17:43
|
Revision: 1187 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1187&view=rev Author: warnes Date: 2007-09-14 23:17:40 -0700 (Fri, 14 Sep 2007) Log Message: ----------- Improve formatting for pdf output Modified Paths: -------------- trunk/SASxport/man/SASxport-package.Rd trunk/SASxport/man/lookup.xport.Rd trunk/SASxport/man/read.xport.Rd trunk/SASxport/man/toSAS.Rd trunk/SASxport/tests/TestUnnamedComponents.Rout.save Modified: trunk/SASxport/man/SASxport-package.Rd =================================================================== --- trunk/SASxport/man/SASxport-package.Rd 2007-09-15 05:06:26 UTC (rev 1186) +++ trunk/SASxport/man/SASxport-package.Rd 2007-09-15 06:17:40 UTC (rev 1187) @@ -53,7 +53,7 @@ \author{ Unless otherwise noted, the contents of this package were written by Gregory R. Warnes \email{gr...@ra...}, are - Copyright (c) 2007 by Random Technologies LLC + Copyright (c) 2007 by Random Technologies LLC \cr \url{http://random-technologies-llc.com}, and are provided under the terms of the GNU General Public License, version 2.0 or later. Modified: trunk/SASxport/man/lookup.xport.Rd =================================================================== --- trunk/SASxport/man/lookup.xport.Rd 2007-09-15 05:06:26 UTC (rev 1186) +++ trunk/SASxport/man/lookup.xport.Rd 2007-09-15 06:17:40 UTC (rev 1187) @@ -52,7 +52,10 @@ ## Or read a copy of test2.xpt available on the web: \dontrun{ -url <- 'http://biostat.mc.vanderbilt.edu/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt' +host <- 'http://biostat.mc.vanderbilt.edu' +path <- '/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt' +url <- paste(host,path,sep="") + w <- lookup.xport(url) # display the information (calls 'print.lookup.xport') Modified: trunk/SASxport/man/read.xport.Rd =================================================================== --- trunk/SASxport/man/read.xport.Rd 2007-09-15 05:06:26 UTC (rev 1186) +++ trunk/SASxport/man/read.xport.Rd 2007-09-15 06:17:40 UTC (rev 1187) @@ -161,7 +161,10 @@ # Or read a copy of test2.xpt available on the web: -url <- 'http://biostat.mc.vanderbilt.edu/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt' +host <- 'http://biostat.mc.vanderbilt.edu' +path <- '/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt' +url <- paste(host,path,sep="") + w <- read.xport(url) Modified: trunk/SASxport/man/toSAS.Rd =================================================================== --- trunk/SASxport/man/toSAS.Rd 2007-09-15 05:06:26 UTC (rev 1186) +++ trunk/SASxport/man/toSAS.Rd 2007-09-15 06:17:40 UTC (rev 1187) @@ -91,7 +91,8 @@ ## Create a new conversion function to store as a RGB hex value toSAS.colorFactor <- function(x, format="") { - retval <- ifelse(x=="Red", "#FF0000", ifelse(x=="Green", "#00FF00", "#0000FF") ) + retval <- ifelse(x=="Red", "#FF0000", + ifelse(x=="Green", "#00FF00", "#0000FF") ) attr(retval, "format") <- format retval } Modified: trunk/SASxport/tests/TestUnnamedComponents.Rout.save =================================================================== --- trunk/SASxport/tests/TestUnnamedComponents.Rout.save 2007-09-15 05:06:26 UTC (rev 1186) +++ trunk/SASxport/tests/TestUnnamedComponents.Rout.save 2007-09-15 06:17:40 UTC (rev 1187) @@ -67,8 +67,12 @@ rd.xpr> ## End(Not run) rd.xpr> rd.xpr> # Or read a copy of test2.xpt available on the web: -rd.xpr> url <- 'http://biostat.mc.vanderbilt.edu/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt' +rd.xpr> host <- 'http://biostat.mc.vanderbilt.edu' +rd.xpr> path <- '/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt' + +rd.xpr> url <- paste(host,path,sep="") + rd.xpr> w <- read.xport(url) rd.xpr> # We can also get the dataset wrapped in a list @@ -420,8 +424,12 @@ rd.xpr> ## End(Not run) rd.xpr> rd.xpr> # Or read a copy of test2.xpt available on the web: -rd.xpr> url <- 'http://biostat.mc.vanderbilt.edu/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt' +rd.xpr> host <- 'http://biostat.mc.vanderbilt.edu' +rd.xpr> path <- '/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt' + +rd.xpr> url <- paste(host,path,sep="") + rd.xpr> w <- read.xport(url) rd.xpr> # We can also get the dataset wrapped in a list @@ -508,8 +516,12 @@ rd.xpr> ## End(Not run) rd.xpr> rd.xpr> # Or read a copy of test2.xpt available on the web: -rd.xpr> url <- 'http://biostat.mc.vanderbilt.edu/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt' +rd.xpr> host <- 'http://biostat.mc.vanderbilt.edu' +rd.xpr> path <- '/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt' + +rd.xpr> url <- paste(host,path,sep="") + rd.xpr> w <- read.xport(url) rd.xpr> # We can also get the dataset wrapped in a list @@ -645,8 +657,12 @@ rd.xpr> ## End(Not run) rd.xpr> rd.xpr> # Or read a copy of test2.xpt available on the web: -rd.xpr> url <- 'http://biostat.mc.vanderbilt.edu/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt' +rd.xpr> host <- 'http://biostat.mc.vanderbilt.edu' +rd.xpr> path <- '/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt' + +rd.xpr> url <- paste(host,path,sep="") + rd.xpr> w <- read.xport(url) rd.xpr> # We can also get the dataset wrapped in a list @@ -657,7 +673,7 @@ rd.xpr> ## Don't show: rd.xpr> SASxport:::assert( is.data.frame(w)==FALSE && is.list(w)==TRUE ) -> colnames(w[[2]]) <- c() +> colnames(w[[2]]) <- rep("", length=ncol(w[[2]])) > write.xport(list=w,file="a.xpt") Warning message: Unnamed variables detected, using default names in: write.xport(list = w, file = "a.xpt") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-09-25 19:58:16
|
Revision: 1191 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1191&view=rev Author: warnes Date: 2007-09-25 12:58:05 -0700 (Tue, 25 Sep 2007) Log Message: ----------- Update version number and date Modified Paths: -------------- trunk/SASxport/DESCRIPTION trunk/SASxport/inst/ChangeLog Modified: trunk/SASxport/DESCRIPTION =================================================================== --- trunk/SASxport/DESCRIPTION 2007-09-25 19:54:11 UTC (rev 1190) +++ trunk/SASxport/DESCRIPTION 2007-09-25 19:58:05 UTC (rev 1191) @@ -1,8 +1,8 @@ Package: SASxport Type: Package Title: Read and Write SAS XPORT Files -Version: 1.1.0 -Date: 2007-09-14 +Version: 1.1.1 +Date: 2007-09-25 Description: This package provides functions for reading, listing the contents of, and writing SAS xport format files. The functions support reading and writing of either Modified: trunk/SASxport/inst/ChangeLog =================================================================== --- trunk/SASxport/inst/ChangeLog 2007-09-25 19:54:11 UTC (rev 1190) +++ trunk/SASxport/inst/ChangeLog 2007-09-25 19:58:05 UTC (rev 1191) @@ -1,3 +1,26 @@ +2007-09-25 19:54 warnes + + * man/SASxport-package.Rd, man/write.xport.Rd: Indicate that Metrum + partially funded development + +2007-09-25 19:53 warnes + + * R/zzz.R: Display version and support information on package load + +2007-09-18 17:42 warnes + + * DESCRIPTION: Spent more time than Metrum paid for + +2007-09-15 06:17 warnes + + * man/SASxport-package.Rd, man/lookup.xport.Rd, man/read.xport.Rd, + man/toSAS.Rd, tests/TestUnnamedComponents.Rout.save: Improve + formatting for pdf output + +2007-09-15 05:06 warnes + + * inst/ChangeLog: Update changelog + 2007-09-15 04:55 warnes * tests/TestUnnamedComponents.R: Changes so test This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-10-02 22:34:16
|
Revision: 1195 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1195&view=rev Author: warnes Date: 2007-10-02 15:34:06 -0700 (Tue, 02 Oct 2007) Log Message: ----------- Add information on how to get help to the startup message Modified Paths: -------------- trunk/SASxport/inst/ChangeLog trunk/SASxport/tests/Alfalfa_Test.Rout.save trunk/SASxport/tests/TestUnnamedComponents.Rout.save trunk/SASxport/tests/Theoph.Rout.save trunk/SASxport/tests/cars.Rout.save trunk/SASxport/tests/testDates.Rout.save trunk/SASxport/tests/test_fields.Rout.save trunk/SASxport/tests/xport.Rout.save trunk/SASxport/tests/xxx.Rout.save Modified: trunk/SASxport/inst/ChangeLog =================================================================== --- trunk/SASxport/inst/ChangeLog 2007-10-02 22:30:31 UTC (rev 1194) +++ trunk/SASxport/inst/ChangeLog 2007-10-02 22:34:06 UTC (rev 1195) @@ -1,367 +0,0 @@ -2007-09-25 19:54 warnes - - * man/SASxport-package.Rd, man/write.xport.Rd: Indicate that Metrum - partially funded development - -2007-09-25 19:53 warnes - - * R/zzz.R: Display version and support information on package load - -2007-09-18 17:42 warnes - - * DESCRIPTION: Spent more time than Metrum paid for - -2007-09-15 06:17 warnes - - * man/SASxport-package.Rd, man/lookup.xport.Rd, man/read.xport.Rd, - man/toSAS.Rd, tests/TestUnnamedComponents.Rout.save: Improve - formatting for pdf output - -2007-09-15 05:06 warnes - - * inst/ChangeLog: Update changelog - -2007-09-15 04:55 warnes - - * tests/TestUnnamedComponents.R: Changes so test - TestUnnamedCompontents.R runs under R 2.4.1 on Win32 - -2007-09-15 04:01 warnes - - * DESCRIPTION, R/make.formats.R, R/toSAS.R, R/write.xport.R, - R/xport.character.R, man/Alfalfa.Rd, man/lookup.xport.Rd, - man/toSAS.Rd, man/write.xport.Rd, tests/Alfalfa_Test.R, - tests/Alfalfa_Test.Rout.save, - tests/TestUnnamedComponents.Rout.save, tests/Theoph.Rout.save, - tests/cars.R, tests/cars.Rout.save, tests/test.xpt, - tests/testDates.Rout.save, tests/test_fields.Rout.save, - tests/xport.Rout.save, tests/xxx.R, tests/xxx.Rout.save: Add - support for auto-generating SAS formats for factor objects. - Refactor argument name handling to improve code clarity. - -2007-09-14 15:35 warnes - - * R/process.formats.R, R/read.xport.R, data, data/Alfalfa.R, - data/Alfalfa.xpt, inst/ChangeLog, man/Alfalfa.Rd, - man/lookup.xport.Rd, man/read.xport.Rd, - tests/TestUnnamedComponents.Rout.save: Add option to read.xport() - that permits inclusion of PROC CONTENTS format information in the - returned list - -2007-09-13 17:36 warnes - - * R/read.xport.R: Ensure 'names.tolower' applies to dataset names - -2007-09-13 01:55 warnes - - * tests/TestUnnamedComponents.Rout.save: Update test output to - match recent changes. - -2007-09-13 01:19 warnes - - * R/write.xport.R: Add checking and handling for unnamed data - frames or variables - -2007-09-13 01:14 warnes - - * tests/Alfalfa_Test.Rout.save, tests/TestUnnamedComponents.R, - tests/TestUnnamedComponents.Rout.save, tests/Theoph.Rout.save, - tests/cars.Rout.save, tests/testDates.Rout.save, - tests/test_fields.Rout.save, tests/xport.Rout.save, - tests/xxx.Rout.save: Update tests now that 'units' and 'units<-' - functions no longer are included - -2007-09-12 22:27 warnes - - * NAMESPACE: Remove units() and units<-() functions since they - arene't ever used. - -2007-09-12 22:25 warnes - - * R/units.R, man/label.Rd, man/units.Rd: Remove units() and - units<-() functions since they arene't ever used. - -2007-09-12 22:24 warnes - - * man/units.Rd: Remove units from manual page - -2007-09-11 23:08 warnes - - * man/read.xport.Rd: Add assertion to test that read.xport(.., - as.list=TRUE) works properly - -2007-09-11 23:05 warnes - - * R/write.xport.R: Forgot to save buffer before svn commit. - -2007-09-11 21:22 warnes - - * R/read.xport.R, man/read.xport.Rd: Correct error in handling - 'verbose' argument, error when more than one dataset has the same - name, and add 'as.list' argument to ensure return value is a - list, even if there is only one dataset in the file - -2007-09-11 21:21 warnes - - * R/write.xport.R, man/write.xport.Rd: Improve handling of list - argument. Also check that names are proper and unique. - -2007-09-07 16:47 warnes - - * tests/Theoph.R, tests/Theoph.Rout.save: Add round-trip test for - Theoph data set - -2007-09-07 16:32 warnes - - * tests/Alfalfa_Test.Rout.save, tests/cars.Rout.save, - tests/testDates.Rout.save, tests/xxx.Rout.save: Change argument - name in write.xport from 'filename' to 'file' to match read.xport - -2007-09-07 16:25 warnes - - * man/write.xport.Rd: Change argument name in write.xport from - 'filename' to 'file' to match read.xport - -2007-09-07 16:23 warnes - - * R/write.xport.R, man/read.xport.Rd, man/write.xport.Rd, - tests/Alfalfa_Test.R, tests/cars.R, tests/testDates.R, - tests/xxx.R: Change argument name in write.xport from 'filename' - to 'file' to match read.xport - -2007-09-07 16:21 warnes - - * DESCRIPTION: Fix typo - -2007-08-29 02:24 warnes - - * DESCRIPTION: Update Version to 1.0, depend on current version of - foreign - -2007-08-22 19:21 warnes - - * ChangeLog, NEWS, inst/ChangeLog, inst/NEWS: Update ChangeLog and - NEWS files - -2007-08-22 18:11 warnes - - * R/read.xport.R, man/read.xport.Rd, tests/xport.Rout.save: Modify - read.xport to preserve case of SAS names by default, as well as - updating the example code. - -2007-08-22 01:19 warnes - - * src/reverse.c: sprintf() was being used where printf() was - intended. - -2007-08-21 18:16 warnes - - * DESCRIPTION: Slight improvement to credits for BRL-CAD - -2007-08-21 18:13 warnes - - * TODO, man/lookup.xport.Rd, man/read.xport.Rd: Commit previous - updates - -2007-08-21 18:12 warnes - - * src/htond.c, src/ibm2ieee.c, src/ieee2ibm.c, src/init.c, - src/reverse.c, src/test_fields.c: Commit previous updates - -2007-08-15 07:02 warnes - - * DESCRIPTION, man/SASxport-package.Rd, src/cnxptiee.c, - src/cnxptiee.h, src/htond.c, src/init.c, src/reverse.c, - src/test_fields.c, src/writeSAS.c, src/writeSAS.h: Remove - dependency on SAS code - -2007-08-15 06:06 warnes - - * src/reverse.c: Fix reverse.c because we need to swap everything - to match Big-Endian, rather than Little-Endian. Also, dont' call - the macro. - -2007-08-15 06:04 warnes - - * src/reverse.c: Restore reverse.c - -2007-08-15 03:17 warnes - - * DESCRIPTION: Minor reformatting - -2007-08-15 03:14 warnes - - * DESCRIPTION, inst/doc/SAS_TS140.txt, inst/doc/index.html, - inst/doc/r2xpt.doc, man/SASxport-package.Rd, man/lookup.xport.Rd, - man/read.xport.Rd, man/toSAS.Rd, man/units.Rd, - man/write.xport.Rd: Make corrections for typos noted by Metrum - folks - -2007-08-12 03:22 warnes - - * DESCRIPTION, man/lookup.xport.Rd, src/cnxptiee.h, - src/test_fields.c, src/writeSAS.h: More updates - -2007-08-12 03:13 warnes - - * src/B8.h, src/IEEEtoIBM.c, src/MASKS.h, src/main.c, - src/reverse.c: Remove new stuff... use SAS's code instead - -2007-08-12 03:12 warnes - - * src/B8.h, src/IEEEtoIBM.c, src/MASKS.h, src/cnxptiee.h, - src/main.c, src/reverse.c, src/test_fields.c, src/writeSAS.h: 1st - attempt at rewriting cnxptiee.[ch] - -2007-08-11 23:48 warnes - - * R/read.xport.R: Explicitly check file header - -2007-08-11 00:03 warnes - - * DESCRIPTION, man/SASxport-package.Rd: Improve package description - -2007-08-09 23:29 warnes - - * DESCRIPTION, NAMESPACE, TODO, man/lookup.xport.Rd, - man/read.xport.Rd, man/units.Rd: More changes, esp to - lookup.xport() and friends - -2007-08-09 23:28 warnes - - * tests/Alfalfa_Test.Rout.save, tests/cars.Rout.save, - tests/xport.Rout.save: More changes, esp to lookup.xport() and - friends - -2007-08-09 23:28 warnes - - * R/AFirst.lib.s, R/all.is.numeric.R, R/in.opererator.R, - R/lookup.xport.R, R/read.xport.R, R/write.xport.R: More changes, - esp to lookup.xport() and friends - -2007-08-09 19:02 warnes - - * src/swap_bytes.h: Remove unused swap_bytes.h - -2007-08-09 19:02 warnes - - * man/SASxport-package.Rd: Add package description page - -2007-08-09 16:54 warnes - - * R/importConvertDateTime.R, R/makeNames.R, R/read.xport.R, - R/testDateTime.R: Add comment header indicating the source of - code from Hmisc - -2007-08-09 16:53 warnes - - * tests/testDates.Rout.save, tests/test_fields.Rout.save, - tests/xport.Rout.save, tests/xxx.Rout.save: Update saved output - of test scripts - -2007-08-08 18:54 warnes - - * DESCRIPTION, NAMESPACE: Updates - -2007-08-08 18:54 warnes - - * tests/Alfalfa_Test.R, tests/Alfalfa_Test.Rout.save, tests/cars.R, - tests/cars.Rout.save, tests/datetime.xpt, tests/testDates.R, - tests/test_fields.R, tests/test_fields.Rout.save, tests/xport.R, - tests/xxx.R, tests/xxx.Rout.save: Updates - -2007-08-08 18:54 warnes - - * src/SASxport.c, src/SASxport.h, src/foreign.h, src/init.c: - Updates - -2007-08-08 18:53 warnes - - * R/AFirst.lib.s, R/formats.R, R/iformat.R, - R/importConvertDateTime.R, R/label.R, R/lookup.xport.R, - R/makeNames.R, R/read.xport.R, R/testDateTime.R, R/units.R, - R/xport.R: Updates - -2007-08-08 18:53 warnes - - * man/assert.Rd, man/read.xport.Rd, man/units.Rd: Updates. - -2007-08-03 04:44 warnes - - * DESCRIPTION, NAMESPACE, R/scat.R, R/xport.R, R/zzz.R, - man/lookup.xport.Rd, man/read.xport.Rd, src/SASxport.c, - src/SASxport.h, src/cnxptiee.c, src/cnxptiee.h, src/foreign.h, - src/init.c, src/swap_bytes.h, src/test_fields.c, src/writeSAS.c, - src/writeSAS.h, tests/Alfalfa_Test.Rout.save, - tests/cars.Rout.save, tests/datetime.xpt, tests/test.xpt, - tests/testDates.Rout.save, tests/test_fields.Rout.save, - tests/xport.R, tests/xport.Rout.save, tests/xxx.Rout.save: Add - code from package foreign and gtools to make SASxport stand alone - -2007-08-03 01:46 warnes - - * R/.Rhistory: Remove stray .Rhistory file - -2007-08-03 01:45 warnes - - * DESCRIPTION: Acknowledge MetrumI support - -2007-08-03 01:45 warnes - - * NAMESPACE: Add "assert" function - -2007-08-03 01:44 warnes - - * R/assert.R, man/assert.Rd: Add "assert" function to avoid - dependenct on gtools. - -2007-08-03 01:29 warnes - - * man/toSAS.Rd, src/cnxptiee.c, src/writeSAS.c: Correct some typos. - -2007-08-03 00:40 warnes - - * DESCRIPTION: Drop version number to 0.99 until testing - integration and is complete - -2007-08-03 00:39 warnes - - * tests/test_fields.R: Add R test file to run c-level tests - -2007-08-03 00:36 warnes - - * src/SASxport.so: Remove .so from svn - -2007-08-03 00:35 warnes - - * NAMESPACE, R/fromSASDate.R, R/parseFormat.R, R/toSAS.R, - R/write.xport.R, R/xport.character.R, R/xport.file.header.R, - R/xport.member.header.R, R/xport.namestr.R, man/toSAS.Rd, - src/SASxport.so, src/writeSAS.c: More modifications. Should now - work for most R data types - -2007-08-03 00:35 warnes - - * tests/cars.R, tests/datetime.xpt, tests/testDates.R, tests/xxx.R: - Add more tests - -2007-07-29 01:15 warnes - - * tests/Alfalfa2.xpt, tests/cars.sas, tests/cars.xpt, - tests/xxx.sas, tests/xxx.xpt: Add SAS code to create xport data - files for testing - -2007-07-28 08:47 warnes - - * ., DESCRIPTION, NAMESPACE, R, R/.Rhistory, R/blanks.R, - R/rawToDisplay.R, R/write.xport.R, R/xport.NA.R, - R/xport.character.R, R/xport.dateFMT.R, R/xport.file.header.R, - R/xport.fill.R, R/xport.member.header.R, R/xport.namestr.R, - R/xport.namestr.header.R, R/xport.numeric.R, - R/xport.obs.header.R, R/zzz.R, inst, inst/doc, - inst/doc/SAS_TS140.txt, inst/doc/index.html, inst/doc/r2xpt.doc, - man, man/write.xport.Rd, src, src/SASxport.so, src/cnxptiee.c, - src/cnxptiee.h, src/test_fields.c, src/writeSAS.c, - src/writeSAS.h, tests, tests/Alfalfa.xpt, tests/Alfalfa2.xpt, - tests/Alfalfa_Test.R: Add SVNxport package - Modified: trunk/SASxport/tests/Alfalfa_Test.Rout.save =================================================================== --- trunk/SASxport/tests/Alfalfa_Test.Rout.save 2007-10-02 22:30:31 UTC (rev 1194) +++ trunk/SASxport/tests/Alfalfa_Test.Rout.save 2007-10-02 22:34:06 UTC (rev 1195) @@ -1,6 +1,6 @@ -R version 2.6.0 beta (2007-09-24 r42966) -Copyright (C) 2007 The R Foundation for Statistical Computing +R version 2.4.1 (2006-12-18) +Copyright (C) 2006 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. @@ -25,6 +25,8 @@ Updates and technical support available from Random Technologies, LLC <http://random-technologies-llc.com/contact> + Type `?SASxport' for usage information. + > > # existing data file > SPEC <- read.xport("Alfalfa.xpt") Modified: trunk/SASxport/tests/TestUnnamedComponents.Rout.save =================================================================== --- trunk/SASxport/tests/TestUnnamedComponents.Rout.save 2007-10-02 22:30:31 UTC (rev 1194) +++ trunk/SASxport/tests/TestUnnamedComponents.Rout.save 2007-10-02 22:34:06 UTC (rev 1195) @@ -1,6 +1,6 @@ -R version 2.6.0 beta (2007-09-24 r42966) -Copyright (C) 2007 The R Foundation for Statistical Computing +R version 2.4.1 (2006-12-18) +Copyright (C) 2006 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. @@ -22,77 +22,30 @@ Updates and technical support available from Random Technologies, LLC <http://random-technologies-llc.com/contact> + Type `?SASxport' for usage information. + > > > ##tests > example(read.xport) -rd.xpr> # ------- -rd.xpr> # SAS code to generate test dataset: -rd.xpr> # ------- -rd.xpr> # libname y SASV5XPT "test2.xpt"; -rd.xpr> # -rd.xpr> # PROC FORMAT; VALUE race 1=green 2=blue 3=purple; RUN; -rd.xpr> # PROC FORMAT CNTLOUT=format;RUN; * Name, e.g. 'format', unimportant; -rd.xpr> # data test; -rd.xpr> # LENGTH race 3 age 4; -rd.xpr> # age=30; label age="Age at Beginning of Study"; -rd.xpr> # race=2; -rd.xpr> # d1='3mar2002'd ; -rd.xpr> # dt1='3mar2002 9:31:02'dt; -rd.xpr> # t1='11:13:45't; -rd.xpr> # output; -rd.xpr> # -rd.xpr> # age=31; -rd.xpr> # race=4; -rd.xpr> # d1='3jun2002'd ; -rd.xpr> # dt1='3jun2002 9:42:07'dt; -rd.xpr> # t1='11:14:13't; -rd.xpr> # output; -rd.xpr> # format d1 mmddyy10. dt1 datetime. t1 time. race race.; -rd.xpr> # run; -rd.xpr> # data z; LENGTH x3 3 x4 4 x5 5 x6 6 x7 7 x8 8; -rd.xpr> # DO i=1 TO 100; -rd.xpr> # x3=ranuni(3); -rd.xpr> # x4=ranuni(5); -rd.xpr> # x5=ranuni(7); -rd.xpr> # x6=ranuni(9); -rd.xpr> # x7=ranuni(11); -rd.xpr> # x8=ranuni(13); -rd.xpr> # output; -rd.xpr> # END; -rd.xpr> # DROP i; -rd.xpr> # RUN; -rd.xpr> # PROC MEANS; RUN; -rd.xpr> # PROC COPY IN=work OUT=y;SELECT test format z;RUN; *Creates test2.xpt; -rd.xpr> # ------ -rd.xpr> -rd.xpr> # Read this dataset from a local file: -rd.xpr> ## Not run: -rd.xpr> ##D w <- read.xport('test2.xpt') -rd.xpr> ## End(Not run) -rd.xpr> -rd.xpr> # Or read a copy of test2.xpt available on the web: -rd.xpr> host <- 'http://biostat.mc.vanderbilt.edu' +rd.xpr> host <- "http://biostat.mc.vanderbilt.edu" -rd.xpr> path <- '/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt' +rd.xpr> path <- "/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt" -rd.xpr> url <- paste(host,path,sep="") +rd.xpr> url <- paste(host, path, sep = "") rd.xpr> w <- read.xport(url) -rd.xpr> # We can also get the dataset wrapped in a list -rd.xpr> w <- read.xport(url, as.list=TRUE) +rd.xpr> w <- read.xport(url, as.list = TRUE) -rd.xpr> # And we can ask for the format information to be included as well. -rd.xpr> w <- read.xport(url, as.list=TRUE, include.formats=TRUE) +rd.xpr> w <- read.xport(url, as.list = TRUE, include.formats = TRUE) -rd.xpr> ## Don't show: -rd.xpr> SASxport:::assert( is.data.frame(w)==FALSE && is.list(w)==TRUE ) +rd.xpr> SASxport:::assert(is.data.frame(w) == FALSE && is.list(w) == + TRUE) > write.xport(w$test,file="a.xpt") Warning message: -In write.xport(w$test, file = "a.xpt") : - Data frame names modified to obey SAS rules +Data frame names modified to obey SAS rules in: write.xport(w$test, file = "a.xpt") > lookup.xport("a.xpt") SAS xport file @@ -168,8 +121,7 @@ > > write.xport(w$test,w$z,file="a.xpt") Warning message: -In write.xport(w$test, w$z, file = "a.xpt") : - Data frame names modified to obey SAS rules +Data frame names modified to obey SAS rules in: write.xport(w$test, w$z, file = "a.xpt") > lookup.xport("a.xpt") SAS xport file @@ -271,8 +223,7 @@ > names(w) <- NULL > write.xport(w[[1]],w[[2]],file="a.xpt") Warning message: -In write.xport(w[[1]], w[[2]], file = "a.xpt") : - Data frame names modified to obey SAS rules +Data frame names modified to obey SAS rules in: write.xport(w[[1]], w[[2]], file = "a.xpt") > lookup.xport("a.xpt") SAS xport file @@ -300,8 +251,7 @@ > names(w) <- NULL > write.xport(list=w,file="a.xpt") Warning message: -In write.xport(list = w, file = "a.xpt") : - Replacing missing or invalid dataset names +Replacing missing or invalid dataset names in: write.xport(list = w, file = "a.xpt") > lookup.xport("a.xpt") SAS xport file @@ -376,85 +326,35 @@ > > ### Check that we catch invalid parameters > failure <- try( write.xport(5,"a.xpt") ) -Error in write.xport(5, "a.xpt") : - '5', 'a.xpt' are not data.frame objects. +Error in write.xport(5, "a.xpt") : '5', 'a.xpt' are not data.frame objects. > SASxport:::assert( "try-error" %in% class(failure) ) > > failure <- try( write.xport(list(a=5,b=6),"a.xpt") ) Error in write.xport(list(a = 5, b = 6), "a.xpt") : - 'list(a = 5, b = 6)', 'a.xpt' are not data.frame objects. + 'list(a = 5, b = 6)', 'a.xpt' are not data.frame objects. > SASxport:::assert( "try-error" %in% class(failure) ) > > > # Check with different list construction function *name* > example(read.xport) -rd.xpr> # ------- -rd.xpr> # SAS code to generate test dataset: -rd.xpr> # ------- -rd.xpr> # libname y SASV5XPT "test2.xpt"; -rd.xpr> # -rd.xpr> # PROC FORMAT; VALUE race 1=green 2=blue 3=purple; RUN; -rd.xpr> # PROC FORMAT CNTLOUT=format;RUN; * Name, e.g. 'format', unimportant; -rd.xpr> # data test; -rd.xpr> # LENGTH race 3 age 4; -rd.xpr> # age=30; label age="Age at Beginning of Study"; -rd.xpr> # race=2; -rd.xpr> # d1='3mar2002'd ; -rd.xpr> # dt1='3mar2002 9:31:02'dt; -rd.xpr> # t1='11:13:45't; -rd.xpr> # output; -rd.xpr> # -rd.xpr> # age=31; -rd.xpr> # race=4; -rd.xpr> # d1='3jun2002'd ; -rd.xpr> # dt1='3jun2002 9:42:07'dt; -rd.xpr> # t1='11:14:13't; -rd.xpr> # output; -rd.xpr> # format d1 mmddyy10. dt1 datetime. t1 time. race race.; -rd.xpr> # run; -rd.xpr> # data z; LENGTH x3 3 x4 4 x5 5 x6 6 x7 7 x8 8; -rd.xpr> # DO i=1 TO 100; -rd.xpr> # x3=ranuni(3); -rd.xpr> # x4=ranuni(5); -rd.xpr> # x5=ranuni(7); -rd.xpr> # x6=ranuni(9); -rd.xpr> # x7=ranuni(11); -rd.xpr> # x8=ranuni(13); -rd.xpr> # output; -rd.xpr> # END; -rd.xpr> # DROP i; -rd.xpr> # RUN; -rd.xpr> # PROC MEANS; RUN; -rd.xpr> # PROC COPY IN=work OUT=y;SELECT test format z;RUN; *Creates test2.xpt; -rd.xpr> # ------ -rd.xpr> -rd.xpr> # Read this dataset from a local file: -rd.xpr> ## Not run: -rd.xpr> ##D w <- read.xport('test2.xpt') -rd.xpr> ## End(Not run) -rd.xpr> -rd.xpr> # Or read a copy of test2.xpt available on the web: -rd.xpr> host <- 'http://biostat.mc.vanderbilt.edu' +rd.xpr> host <- "http://biostat.mc.vanderbilt.edu" -rd.xpr> path <- '/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt' +rd.xpr> path <- "/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt" -rd.xpr> url <- paste(host,path,sep="") +rd.xpr> url <- paste(host, path, sep = "") rd.xpr> w <- read.xport(url) -rd.xpr> # We can also get the dataset wrapped in a list -rd.xpr> w <- read.xport(url, as.list=TRUE) +rd.xpr> w <- read.xport(url, as.list = TRUE) -rd.xpr> # And we can ask for the format information to be included as well. -rd.xpr> w <- read.xport(url, as.list=TRUE, include.formats=TRUE) +rd.xpr> w <- read.xport(url, as.list = TRUE, include.formats = TRUE) -rd.xpr> ## Don't show: -rd.xpr> SASxport:::assert( is.data.frame(w)==FALSE && is.list(w)==TRUE ) +rd.xpr> SASxport:::assert(is.data.frame(w) == FALSE && is.list(w) == + TRUE) > write.xport(list=base::list(w$test,w$z),file="a.xpt") Warning message: -In write.xport(list = base::list(w$test, w$z), file = "a.xpt") : - Replacing missing or invalid dataset names +Replacing missing or invalid dataset names in: write.xport(list = base::list(w$test, w$z), file = "a.xpt") > lookup.xport("a.xpt") SAS xport file @@ -482,73 +382,24 @@ > # remove names > example(read.xport) -rd.xpr> # ------- -rd.xpr> # SAS code to generate test dataset: -rd.xpr> # ------- -rd.xpr> # libname y SASV5XPT "test2.xpt"; -rd.xpr> # -rd.xpr> # PROC FORMAT; VALUE race 1=green 2=blue 3=purple; RUN; -rd.xpr> # PROC FORMAT CNTLOUT=format;RUN; * Name, e.g. 'format', unimportant; -rd.xpr> # data test; -rd.xpr> # LENGTH race 3 age 4; -rd.xpr> # age=30; label age="Age at Beginning of Study"; -rd.xpr> # race=2; -rd.xpr> # d1='3mar2002'd ; -rd.xpr> # dt1='3mar2002 9:31:02'dt; -rd.xpr> # t1='11:13:45't; -rd.xpr> # output; -rd.xpr> # -rd.xpr> # age=31; -rd.xpr> # race=4; -rd.xpr> # d1='3jun2002'd ; -rd.xpr> # dt1='3jun2002 9:42:07'dt; -rd.xpr> # t1='11:14:13't; -rd.xpr> # output; -rd.xpr> # format d1 mmddyy10. dt1 datetime. t1 time. race race.; -rd.xpr> # run; -rd.xpr> # data z; LENGTH x3 3 x4 4 x5 5 x6 6 x7 7 x8 8; -rd.xpr> # DO i=1 TO 100; -rd.xpr> # x3=ranuni(3); -rd.xpr> # x4=ranuni(5); -rd.xpr> # x5=ranuni(7); -rd.xpr> # x6=ranuni(9); -rd.xpr> # x7=ranuni(11); -rd.xpr> # x8=ranuni(13); -rd.xpr> # output; -rd.xpr> # END; -rd.xpr> # DROP i; -rd.xpr> # RUN; -rd.xpr> # PROC MEANS; RUN; -rd.xpr> # PROC COPY IN=work OUT=y;SELECT test format z;RUN; *Creates test2.xpt; -rd.xpr> # ------ -rd.xpr> -rd.xpr> # Read this dataset from a local file: -rd.xpr> ## Not run: -rd.xpr> ##D w <- read.xport('test2.xpt') -rd.xpr> ## End(Not run) -rd.xpr> -rd.xpr> # Or read a copy of test2.xpt available on the web: -rd.xpr> host <- 'http://biostat.mc.vanderbilt.edu' +rd.xpr> host <- "http://biostat.mc.vanderbilt.edu" -rd.xpr> path <- '/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt' +rd.xpr> path <- "/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt" -rd.xpr> url <- paste(host,path,sep="") +rd.xpr> url <- paste(host, path, sep = "") rd.xpr> w <- read.xport(url) -rd.xpr> # We can also get the dataset wrapped in a list -rd.xpr> w <- read.xport(url, as.list=TRUE) +rd.xpr> w <- read.xport(url, as.list = TRUE) -rd.xpr> # And we can ask for the format information to be included as well. -rd.xpr> w <- read.xport(url, as.list=TRUE, include.formats=TRUE) +rd.xpr> w <- read.xport(url, as.list = TRUE, include.formats = TRUE) -rd.xpr> ## Don't show: -rd.xpr> SASxport:::assert( is.data.frame(w)==FALSE && is.list(w)==TRUE ) +rd.xpr> SASxport:::assert(is.data.frame(w) == FALSE && is.list(w) == + TRUE) > names(w) <- NULL > write.xport(list=w,file="a.xpt") Warning message: -In write.xport(list = w, file = "a.xpt") : - Replacing missing or invalid dataset names +Replacing missing or invalid dataset names in: write.xport(list = w, file = "a.xpt") > lookup.xport("a.xpt") SAS xport file @@ -624,73 +475,24 @@ > # remove variable names > example(read.xport) -rd.xpr> # ------- -rd.xpr> # SAS code to generate test dataset: -rd.xpr> # ------- -rd.xpr> # libname y SASV5XPT "test2.xpt"; -rd.xpr> # -rd.xpr> # PROC FORMAT; VALUE race 1=green 2=blue 3=purple; RUN; -rd.xpr> # PROC FORMAT CNTLOUT=format;RUN; * Name, e.g. 'format', unimportant; -rd.xpr> # data test; -rd.xpr> # LENGTH race 3 age 4; -rd.xpr> # age=30; label age="Age at Beginning of Study"; -rd.xpr> # race=2; -rd.xpr> # d1='3mar2002'd ; -rd.xpr> # dt1='3mar2002 9:31:02'dt; -rd.xpr> # t1='11:13:45't; -rd.xpr> # output; -rd.xpr> # -rd.xpr> # age=31; -rd.xpr> # race=4; -rd.xpr> # d1='3jun2002'd ; -rd.xpr> # dt1='3jun2002 9:42:07'dt; -rd.xpr> # t1='11:14:13't; -rd.xpr> # output; -rd.xpr> # format d1 mmddyy10. dt1 datetime. t1 time. race race.; -rd.xpr> # run; -rd.xpr> # data z; LENGTH x3 3 x4 4 x5 5 x6 6 x7 7 x8 8; -rd.xpr> # DO i=1 TO 100; -rd.xpr> # x3=ranuni(3); -rd.xpr> # x4=ranuni(5); -rd.xpr> # x5=ranuni(7); -rd.xpr> # x6=ranuni(9); -rd.xpr> # x7=ranuni(11); -rd.xpr> # x8=ranuni(13); -rd.xpr> # output; -rd.xpr> # END; -rd.xpr> # DROP i; -rd.xpr> # RUN; -rd.xpr> # PROC MEANS; RUN; -rd.xpr> # PROC COPY IN=work OUT=y;SELECT test format z;RUN; *Creates test2.xpt; -rd.xpr> # ------ -rd.xpr> -rd.xpr> # Read this dataset from a local file: -rd.xpr> ## Not run: -rd.xpr> ##D w <- read.xport('test2.xpt') -rd.xpr> ## End(Not run) -rd.xpr> -rd.xpr> # Or read a copy of test2.xpt available on the web: -rd.xpr> host <- 'http://biostat.mc.vanderbilt.edu' +rd.xpr> host <- "http://biostat.mc.vanderbilt.edu" -rd.xpr> path <- '/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt' +rd.xpr> path <- "/cgi-bin/viewvc.cgi/*checkout*/Hmisc/trunk/tests/test2.xpt" -rd.xpr> url <- paste(host,path,sep="") +rd.xpr> url <- paste(host, path, sep = "") rd.xpr> w <- read.xport(url) -rd.xpr> # We can also get the dataset wrapped in a list -rd.xpr> w <- read.xport(url, as.list=TRUE) +rd.xpr> w <- read.xport(url, as.list = TRUE) -rd.xpr> # And we can ask for the format information to be included as well. -rd.xpr> w <- read.xport(url, as.list=TRUE, include.formats=TRUE) +rd.xpr> w <- read.xport(url, as.list = TRUE, include.formats = TRUE) -rd.xpr> ## Don't show: -rd.xpr> SASxport:::assert( is.data.frame(w)==FALSE && is.list(w)==TRUE ) +rd.xpr> SASxport:::assert(is.data.frame(w) == FALSE && is.list(w) == + TRUE) > colnames(w[[2]]) <- rep("", length=ncol(w[[2]])) > write.xport(list=w,file="a.xpt") Warning message: -In write.xport(list = w, file = "a.xpt") : - Unnamed variables detected, using default names +Unnamed variables detected, using default names in: write.xport(list = w, file = "a.xpt") > lookup.xport("a.xpt") SAS xport file Modified: trunk/SASxport/tests/Theoph.Rout.save =================================================================== --- trunk/SASxport/tests/Theoph.Rout.save 2007-10-02 22:30:31 UTC (rev 1194) +++ trunk/SASxport/tests/Theoph.Rout.save 2007-10-02 22:34:06 UTC (rev 1195) @@ -1,6 +1,6 @@ -R version 2.6.0 beta (2007-09-24 r42966) -Copyright (C) 2007 The R Foundation for Statistical Computing +R version 2.4.1 (2006-12-18) +Copyright (C) 2006 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. @@ -27,6 +27,8 @@ Updates and technical support available from Random Technologies, LLC <http://random-technologies-llc.com/contact> + Type `?SASxport' for usage information. + > > write.xport(Theoph,file="theoph.xpt") > Theoph.2 <- read.xport("theoph.xpt") Modified: trunk/SASxport/tests/cars.Rout.save =================================================================== --- trunk/SASxport/tests/cars.Rout.save 2007-10-02 22:30:31 UTC (rev 1194) +++ trunk/SASxport/tests/cars.Rout.save 2007-10-02 22:34:06 UTC (rev 1195) @@ -1,6 +1,6 @@ -R version 2.6.0 beta (2007-09-24 r42966) -Copyright (C) 2007 The R Foundation for Statistical Computing +R version 2.4.1 (2006-12-18) +Copyright (C) 2006 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. @@ -22,6 +22,8 @@ Updates and technical support available from Random Technologies, LLC <http://random-technologies-llc.com/contact> + Type `?SASxport' for usage information. + > > > cars <- read.table(file="cars.sas", skip=3, nrows=26, Modified: trunk/SASxport/tests/testDates.Rout.save =================================================================== --- trunk/SASxport/tests/testDates.Rout.save 2007-10-02 22:30:31 UTC (rev 1194) +++ trunk/SASxport/tests/testDates.Rout.save 2007-10-02 22:34:06 UTC (rev 1195) @@ -1,6 +1,6 @@ -R version 2.6.0 beta (2007-09-24 r42966) -Copyright (C) 2007 The R Foundation for Statistical Computing +R version 2.4.1 (2006-12-18) +Copyright (C) 2006 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. @@ -22,6 +22,8 @@ Updates and technical support available from Random Technologies, LLC <http://random-technologies-llc.com/contact> + Type `?SASxport' for usage information. + > > ## Create a small data set containing dates, times, and date-times > @@ -45,8 +47,7 @@ > > write.xport( DATETIME=temp, file="datetime.xpt") Warning message: -In write.xport(DATETIME = temp, file = "datetime.xpt") : - Variable names modified to obey SAS rules +Variable names modified to obey SAS rules in: write.xport(DATETIME = temp, file = "datetime.xpt") > temp2 <- read.xport(file="datetime.xpt", names.tolower=FALSE) > > print(temp2) Modified: trunk/SASxport/tests/test_fields.Rout.save =================================================================== --- trunk/SASxport/tests/test_fields.Rout.save 2007-10-02 22:30:31 UTC (rev 1194) +++ trunk/SASxport/tests/test_fields.Rout.save 2007-10-02 22:34:06 UTC (rev 1195) @@ -1,6 +1,6 @@ -R version 2.6.0 beta (2007-09-24 r42966) -Copyright (C) 2007 The R Foundation for Statistical Computing +R version 2.4.1 (2006-12-18) +Copyright (C) 2006 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. @@ -22,6 +22,8 @@ Updates and technical support available from Random Technologies, LLC <http://random-technologies-llc.com/contact> + Type `?SASxport' for usage information. + > > ## Call C-level test routines > Modified: trunk/SASxport/tests/xport.Rout.save =================================================================== --- trunk/SASxport/tests/xport.Rout.save 2007-10-02 22:30:31 UTC (rev 1194) +++ trunk/SASxport/tests/xport.Rout.save 2007-10-02 22:34:06 UTC (rev 1195) @@ -1,6 +1,6 @@ -R version 2.6.0 beta (2007-09-24 r42966) -Copyright (C) 2007 The R Foundation for Statistical Computing +R version 2.4.1 (2006-12-18) +Copyright (C) 2006 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. @@ -22,6 +22,8 @@ Updates and technical support available from Random Technologies, LLC <http://random-technologies-llc.com/contact> + Type `?SASxport' for usage information. + > > lookup.xport("Alfalfa.xpt") Modified: trunk/SASxport/tests/xxx.Rout.save =================================================================== --- trunk/SASxport/tests/xxx.Rout.save 2007-10-02 22:30:31 UTC (rev 1194) +++ trunk/SASxport/tests/xxx.Rout.save 2007-10-02 22:34:06 UTC (rev 1195) @@ -1,6 +1,6 @@ -R version 2.6.0 beta (2007-09-24 r42966) -Copyright (C) 2007 The R Foundation for Statistical Computing +R version 2.4.1 (2006-12-18) +Copyright (C) 2006 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. @@ -22,6 +22,8 @@ Updates and technical support available from Random Technologies, LLC <http://random-technologies-llc.com/contact> + Type `?SASxport' for usage information. + > > ## manually create a data set > abc <- data.frame( x=c(1, 2, NA, NA ), y=c('a', 'B', NA, '*' ) ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-10-29 15:37:08
|
Revision: 1200 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1200&view=rev Author: warnes Date: 2007-10-29 08:37:04 -0700 (Mon, 29 Oct 2007) Log Message: ----------- Fixes to correct handling storage of negative numbers Modified Paths: -------------- trunk/SASxport/DESCRIPTION trunk/SASxport/R/xport.numeric.R trunk/SASxport/inst/ChangeLog trunk/SASxport/src/ibm2ieee.c trunk/SASxport/src/ieee2ibm.c Added Paths: ----------- trunk/SASxport/tests/testNegative.R Modified: trunk/SASxport/DESCRIPTION =================================================================== --- trunk/SASxport/DESCRIPTION 2007-10-29 15:35:53 UTC (rev 1199) +++ trunk/SASxport/DESCRIPTION 2007-10-29 15:37:04 UTC (rev 1200) @@ -1,8 +1,8 @@ Package: SASxport Type: Package Title: Read and Write SAS XPORT Files -Version: 1.1.1 -Date: 2007-09-25 +Version: 1.1.2 +Date: 2007-10-29 Description: This package provides functions for reading, listing the contents of, and writing SAS xport format files. The functions support reading and writing of either Modified: trunk/SASxport/R/xport.numeric.R =================================================================== --- trunk/SASxport/R/xport.numeric.R 2007-10-29 15:35:53 UTC (rev 1199) +++ trunk/SASxport/R/xport.numeric.R 2007-10-29 15:37:04 UTC (rev 1200) @@ -3,7 +3,7 @@ if(length(value)!=1) stop("Only a single numeric value is permitted.") if(is.na(value)) return( xport.NA() ) - + .C("fill_numeric_field", value = as.double(value), NAOK=TRUE, Modified: trunk/SASxport/inst/ChangeLog =================================================================== --- trunk/SASxport/inst/ChangeLog 2007-10-29 15:35:53 UTC (rev 1199) +++ trunk/SASxport/inst/ChangeLog 2007-10-29 15:37:04 UTC (rev 1200) @@ -0,0 +1,398 @@ +2007-10-02 22:34 warnes + + * inst/ChangeLog, tests/Alfalfa_Test.Rout.save, + tests/TestUnnamedComponents.Rout.save, tests/Theoph.Rout.save, + tests/cars.Rout.save, tests/testDates.Rout.save, + tests/test_fields.Rout.save, tests/xport.Rout.save, + tests/xxx.Rout.save: Add information on how to get help to the + startup message + +2007-10-02 22:30 warnes + + * R/zzz.R: Add information on how to get help to the startup + message + +2007-10-02 21:21 warnes + + * NAMESPACE: Add dependenct on utils::packageDescription + +2007-10-01 20:09 warnes + + * tests/Alfalfa_Test.Rout.save, + tests/TestUnnamedComponents.Rout.save, tests/Theoph.Rout.save, + tests/cars.Rout.save, tests/testDates.Rout.save, + tests/test_fields.Rout.save, tests/xport.Rout.save, + tests/xxx.Rout.save: Update saved R output to include startup + message + +2007-09-25 19:58 warnes + + * DESCRIPTION, inst/ChangeLog: Update version number and date + +2007-09-25 19:54 warnes + + * man/SASxport-package.Rd, man/write.xport.Rd: Indicate that Metrum + partially funded development + +2007-09-25 19:53 warnes + + * R/zzz.R: Display version and support information on package load + +2007-09-18 17:42 warnes + + * DESCRIPTION: Spent more time than Metrum paid for + +2007-09-15 06:17 warnes + + * man/SASxport-package.Rd, man/lookup.xport.Rd, man/read.xport.Rd, + man/toSAS.Rd, tests/TestUnnamedComponents.Rout.save: Improve + formatting for pdf output + +2007-09-15 05:06 warnes + + * inst/ChangeLog: Update changelog + +2007-09-15 04:55 warnes + + * tests/TestUnnamedComponents.R: Changes so test + TestUnnamedCompontents.R runs under R 2.4.1 on Win32 + +2007-09-15 04:01 warnes + + * DESCRIPTION, R/make.formats.R, R/toSAS.R, R/write.xport.R, + R/xport.character.R, man/Alfalfa.Rd, man/lookup.xport.Rd, + man/toSAS.Rd, man/write.xport.Rd, tests/Alfalfa_Test.R, + tests/Alfalfa_Test.Rout.save, + tests/TestUnnamedComponents.Rout.save, tests/Theoph.Rout.save, + tests/cars.R, tests/cars.Rout.save, tests/test.xpt, + tests/testDates.Rout.save, tests/test_fields.Rout.save, + tests/xport.Rout.save, tests/xxx.R, tests/xxx.Rout.save: Add + support for auto-generating SAS formats for factor objects. + Refactor argument name handling to improve code clarity. + +2007-09-14 15:35 warnes + + * R/process.formats.R, R/read.xport.R, data, data/Alfalfa.R, + data/Alfalfa.xpt, inst/ChangeLog, man/Alfalfa.Rd, + man/lookup.xport.Rd, man/read.xport.Rd, + tests/TestUnnamedComponents.Rout.save: Add option to read.xport() + that permits inclusion of PROC CONTENTS format information in the + returned list + +2007-09-13 17:36 warnes + + * R/read.xport.R: Ensure 'names.tolower' applies to dataset names + +2007-09-13 01:55 warnes + + * tests/TestUnnamedComponents.Rout.save: Update test output to + match recent changes. + +2007-09-13 01:19 warnes + + * R/write.xport.R: Add checking and handling for unnamed data + frames or variables + +2007-09-13 01:14 warnes + + * tests/Alfalfa_Test.Rout.save, tests/TestUnnamedComponents.R, + tests/TestUnnamedComponents.Rout.save, tests/Theoph.Rout.save, + tests/cars.Rout.save, tests/testDates.Rout.save, + tests/test_fields.Rout.save, tests/xport.Rout.save, + tests/xxx.Rout.save: Update tests now that 'units' and 'units<-' + functions no longer are included + +2007-09-12 22:27 warnes + + * NAMESPACE: Remove units() and units<-() functions since they + arene't ever used. + +2007-09-12 22:25 warnes + + * R/units.R, man/label.Rd, man/units.Rd: Remove units() and + units<-() functions since they arene't ever used. + +2007-09-12 22:24 warnes + + * man/units.Rd: Remove units from manual page + +2007-09-11 23:08 warnes + + * man/read.xport.Rd: Add assertion to test that read.xport(.., + as.list=TRUE) works properly + +2007-09-11 23:05 warnes + + * R/write.xport.R: Forgot to save buffer before svn commit. + +2007-09-11 21:22 warnes + + * R/read.xport.R, man/read.xport.Rd: Correct error in handling + 'verbose' argument, error when more than one dataset has the same + name, and add 'as.list' argument to ensure return value is a + list, even if there is only one dataset in the file + +2007-09-11 21:21 warnes + + * R/write.xport.R, man/write.xport.Rd: Improve handling of list + argument. Also check that names are proper and unique. + +2007-09-07 16:47 warnes + + * tests/Theoph.R, tests/Theoph.Rout.save: Add round-trip test for + Theoph data set + +2007-09-07 16:32 warnes + + * tests/Alfalfa_Test.Rout.save, tests/cars.Rout.save, + tests/testDates.Rout.save, tests/xxx.Rout.save: Change argument + name in write.xport from 'filename' to 'file' to match read.xport + +2007-09-07 16:25 warnes + + * man/write.xport.Rd: Change argument name in write.xport from + 'filename' to 'file' to match read.xport + +2007-09-07 16:23 warnes + + * R/write.xport.R, man/read.xport.Rd, man/write.xport.Rd, + tests/Alfalfa_Test.R, tests/cars.R, tests/testDates.R, + tests/xxx.R: Change argument name in write.xport from 'filename' + to 'file' to match read.xport + +2007-09-07 16:21 warnes + + * DESCRIPTION: Fix typo + +2007-08-29 02:24 warnes + + * DESCRIPTION: Update Version to 1.0, depend on current version of + foreign + +2007-08-22 19:21 warnes + + * ChangeLog, NEWS, inst/ChangeLog, inst/NEWS: Update ChangeLog and + NEWS files + +2007-08-22 18:11 warnes + + * R/read.xport.R, man/read.xport.Rd, tests/xport.Rout.save: Modify + read.xport to preserve case of SAS names by default, as well as + updating the example code. + +2007-08-22 01:19 warnes + + * src/reverse.c: sprintf() was being used where printf() was + intended. + +2007-08-21 18:16 warnes + + * DESCRIPTION: Slight improvement to credits for BRL-CAD + +2007-08-21 18:13 warnes + + * TODO, man/lookup.xport.Rd, man/read.xport.Rd: Commit previous + updates + +2007-08-21 18:12 warnes + + * src/htond.c, src/ibm2ieee.c, src/ieee2ibm.c, src/init.c, + src/reverse.c, src/test_fields.c: Commit previous updates + +2007-08-15 07:02 warnes + + * DESCRIPTION, man/SASxport-package.Rd, src/cnxptiee.c, + src/cnxptiee.h, src/htond.c, src/init.c, src/reverse.c, + src/test_fields.c, src/writeSAS.c, src/writeSAS.h: Remove + dependency on SAS code + +2007-08-15 06:06 warnes + + * src/reverse.c: Fix reverse.c because we need to swap everything + to match Big-Endian, rather than Little-Endian. Also, dont' call + the macro. + +2007-08-15 06:04 warnes + + * src/reverse.c: Restore reverse.c + +2007-08-15 03:17 warnes + + * DESCRIPTION: Minor reformatting + +2007-08-15 03:14 warnes + + * DESCRIPTION, inst/doc/SAS_TS140.txt, inst/doc/index.html, + inst/doc/r2xpt.doc, man/SASxport-package.Rd, man/lookup.xport.Rd, + man/read.xport.Rd, man/toSAS.Rd, man/units.Rd, + man/write.xport.Rd: Make corrections for typos noted by Metrum + folks + +2007-08-12 03:22 warnes + + * DESCRIPTION, man/lookup.xport.Rd, src/cnxptiee.h, + src/test_fields.c, src/writeSAS.h: More updates + +2007-08-12 03:13 warnes + + * src/B8.h, src/IEEEtoIBM.c, src/MASKS.h, src/main.c, + src/reverse.c: Remove new stuff... use SAS's code instead + +2007-08-12 03:12 warnes + + * src/B8.h, src/IEEEtoIBM.c, src/MASKS.h, src/cnxptiee.h, + src/main.c, src/reverse.c, src/test_fields.c, src/writeSAS.h: 1st + attempt at rewriting cnxptiee.[ch] + +2007-08-11 23:48 warnes + + * R/read.xport.R: Explicitly check file header + +2007-08-11 00:03 warnes + + * DESCRIPTION, man/SASxport-package.Rd: Improve package description + +2007-08-09 23:29 warnes + + * DESCRIPTION, NAMESPACE, TODO, man/lookup.xport.Rd, + man/read.xport.Rd, man/units.Rd: More changes, esp to + lookup.xport() and friends + +2007-08-09 23:28 warnes + + * tests/Alfalfa_Test.Rout.save, tests/cars.Rout.save, + tests/xport.Rout.save: More changes, esp to lookup.xport() and + friends + +2007-08-09 23:28 warnes + + * R/AFirst.lib.s, R/all.is.numeric.R, R/in.opererator.R, + R/lookup.xport.R, R/read.xport.R, R/write.xport.R: More changes, + esp to lookup.xport() and friends + +2007-08-09 19:02 warnes + + * src/swap_bytes.h: Remove unused swap_bytes.h + +2007-08-09 19:02 warnes + + * man/SASxport-package.Rd: Add package description page + +2007-08-09 16:54 warnes + + * R/importConvertDateTime.R, R/makeNames.R, R/read.xport.R, + R/testDateTime.R: Add comment header indicating the source of + code from Hmisc + +2007-08-09 16:53 warnes + + * tests/testDates.Rout.save, tests/test_fields.Rout.save, + tests/xport.Rout.save, tests/xxx.Rout.save: Update saved output + of test scripts + +2007-08-08 18:54 warnes + + * DESCRIPTION, NAMESPACE: Updates + +2007-08-08 18:54 warnes + + * tests/Alfalfa_Test.R, tests/Alfalfa_Test.Rout.save, tests/cars.R, + tests/cars.Rout.save, tests/datetime.xpt, tests/testDates.R, + tests/test_fields.R, tests/test_fields.Rout.save, tests/xport.R, + tests/xxx.R, tests/xxx.Rout.save: Updates + +2007-08-08 18:54 warnes + + * src/SASxport.c, src/SASxport.h, src/foreign.h, src/init.c: + Updates + +2007-08-08 18:53 warnes + + * R/AFirst.lib.s, R/formats.R, R/iformat.R, + R/importConvertDateTime.R, R/label.R, R/lookup.xport.R, + R/makeNames.R, R/read.xport.R, R/testDateTime.R, R/units.R, + R/xport.R: Updates + +2007-08-08 18:53 warnes + + * man/assert.Rd, man/read.xport.Rd, man/units.Rd: Updates. + +2007-08-03 04:44 warnes + + * DESCRIPTION, NAMESPACE, R/scat.R, R/xport.R, R/zzz.R, + man/lookup.xport.Rd, man/read.xport.Rd, src/SASxport.c, + src/SASxport.h, src/cnxptiee.c, src/cnxptiee.h, src/foreign.h, + src/init.c, src/swap_bytes.h, src/test_fields.c, src/writeSAS.c, + src/writeSAS.h, tests/Alfalfa_Test.Rout.save, + tests/cars.Rout.save, tests/datetime.xpt, tests/test.xpt, + tests/testDates.Rout.save, tests/test_fields.Rout.save, + tests/xport.R, tests/xport.Rout.save, tests/xxx.Rout.save: Add + code from package foreign and gtools to make SASxport stand alone + +2007-08-03 01:46 warnes + + * R/.Rhistory: Remove stray .Rhistory file + +2007-08-03 01:45 warnes + + * DESCRIPTION: Acknowledge MetrumI support + +2007-08-03 01:45 warnes + + * NAMESPACE: Add "assert" function + +2007-08-03 01:44 warnes + + * R/assert.R, man/assert.Rd: Add "assert" function to avoid + dependenct on gtools. + +2007-08-03 01:29 warnes + + * man/toSAS.Rd, src/cnxptiee.c, src/writeSAS.c: Correct some typos. + +2007-08-03 00:40 warnes + + * DESCRIPTION: Drop version number to 0.99 until testing + integration and is complete + +2007-08-03 00:39 warnes + + * tests/test_fields.R: Add R test file to run c-level tests + +2007-08-03 00:36 warnes + + * src/SASxport.so: Remove .so from svn + +2007-08-03 00:35 warnes + + * NAMESPACE, R/fromSASDate.R, R/parseFormat.R, R/toSAS.R, + R/write.xport.R, R/xport.character.R, R/xport.file.header.R, + R/xport.member.header.R, R/xport.namestr.R, man/toSAS.Rd, + src/SASxport.so, src/writeSAS.c: More modifications. Should now + work for most R data types + +2007-08-03 00:35 warnes + + * tests/cars.R, tests/datetime.xpt, tests/testDates.R, tests/xxx.R: + Add more tests + +2007-07-29 01:15 warnes + + * tests/Alfalfa2.xpt, tests/cars.sas, tests/cars.xpt, + tests/xxx.sas, tests/xxx.xpt: Add SAS code to create xport data + files for testing + +2007-07-28 08:47 warnes + + * ., DESCRIPTION, NAMESPACE, R, R/.Rhistory, R/blanks.R, + R/rawToDisplay.R, R/write.xport.R, R/xport.NA.R, + R/xport.character.R, R/xport.dateFMT.R, R/xport.file.header.R, + R/xport.fill.R, R/xport.member.header.R, R/xport.namestr.R, + R/xport.namestr.header.R, R/xport.numeric.R, + R/xport.obs.header.R, R/zzz.R, inst, inst/doc, + inst/doc/SAS_TS140.txt, inst/doc/index.html, inst/doc/r2xpt.doc, + man, man/write.xport.Rd, src, src/SASxport.so, src/cnxptiee.c, + src/cnxptiee.h, src/test_fields.c, src/writeSAS.c, + src/writeSAS.h, tests, tests/Alfalfa.xpt, tests/Alfalfa2.xpt, + tests/Alfalfa_Test.R: Add SVNxport package + Modified: trunk/SASxport/src/ibm2ieee.c =================================================================== --- trunk/SASxport/src/ibm2ieee.c 2007-10-29 15:35:53 UTC (rev 1199) +++ trunk/SASxport/src/ibm2ieee.c 2007-10-29 15:37:04 UTC (rev 1200) @@ -86,7 +86,9 @@ signbit = left & 0x80000000; left &= 0x00FFFFFF; - if( signbit ) { + + /*if( signbit ) {*/ + if( 0 ) { /* The IBM uses 2's compliment on the mantissa, * and IEEE does not. */ Modified: trunk/SASxport/src/ieee2ibm.c =================================================================== --- trunk/SASxport/src/ieee2ibm.c 2007-10-29 15:35:53 UTC (rev 1199) +++ trunk/SASxport/src/ieee2ibm.c 2007-10-29 15:37:04 UTC (rev 1200) @@ -50,8 +50,8 @@ */ register int i; for( i=count-1; i >= 0; i-- ) { - register unsigned long left, right; - register int fix, exp, signbit; + register unsigned long left, right; + register int fix, exp, signbit; left = (in[0]<<24) | (in[1]<<16) | (in[2]<<8) | in[3]; right = (in[4]<<24) | (in[5]<<16) | (in[6]<<8) | in[7]; @@ -59,6 +59,7 @@ exp = ((left >> 20) & 0x7FF); signbit = (left & 0x80000000) >> 24; + if( exp == 0 || exp == 0x7FF ) { ibm_undef: *out++ = 0; /* IBM zero. No NAN */ *out++ = 0; @@ -88,7 +89,8 @@ right <<= fix; } - if( signbit ) { + /* if( 0 && signbit ) { */ + if( 0 ) { /* The IBM actually uses complimented mantissa * and exponent. */ @@ -109,7 +111,6 @@ exp = (~exp) & 0x7F; } - /* Not actually required, but for comparison purposes, * normalize the number. Remove for production speed. */ Added: trunk/SASxport/tests/testNegative.R =================================================================== --- trunk/SASxport/tests/testNegative.R (rev 0) +++ trunk/SASxport/tests/testNegative.R 2007-10-29 15:37:04 UTC (rev 1200) @@ -0,0 +1,16 @@ +library(SASxport) + +df1 <- data.frame( f=c(1.0, -1.0), d=as.integer(c(-1,1) ) ) +write.xport(df1, file='df1.xpt') +df2 <- read.xport(file='df1.xpt') + +print(df1) +print(df2) + +SASxport:::assert(all(df1==df2)) + +df3 <- data.frame(x.continuous=seq(-100,100,by=0.5), x.integer=as.integer(seq(-100,100,by=0.5)) ) +write.xport(df3, file='df3.xpt') +df4 <- read.xport(file='df3.xpt') + +SASxport:::assert(all(df3==df4)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-11-01 06:01:53
|
Revision: 1202 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1202&view=rev Author: warnes Date: 2007-10-31 23:01:50 -0700 (Wed, 31 Oct 2007) Log Message: ----------- Copy code from foreign for lookup.xport() and read.xport(), extend lookup.xport() to show information about SAS format and iformat Added Paths: ----------- trunk/SASxport/R/xport.R trunk/SASxport/src/SASxport.c trunk/SASxport/src/SASxport.h Added: trunk/SASxport/R/xport.R =================================================================== --- trunk/SASxport/R/xport.R (rev 0) +++ trunk/SASxport/R/xport.R 2007-11-01 06:01:50 UTC (rev 1202) @@ -0,0 +1,32 @@ +### This file is part of the 'foreign' package for R. + +### +### Read SAS xport format libraries +### +### Copyright 1999-1999 Douglas M. Bates <bates$stat.wisc.edu>, +### Saikat DebRoy <saikat$stat.wisc.edu> +### +### This file is part of the `foreign' library for R and related languages. +### It is made available under the terms of the GNU General Public +### License, version 2, or at your option, any later version, +### incorporated herein by reference. +### +### This program is distributed in the hope that it will be +### useful, but WITHOUT ANY WARRANTY; without even the implied +### warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +### PURPOSE. See the GNU General Public License for more +### details. +### +### You should have received a copy of the GNU General Public +### License along with this program; if not, a copy is available at +### http://www.r-project.org/Licenses/ + +lookup.xport.inner <- function(file) .Call(xport_info, file) + + +read.xport.inner <- function(file) { + data.info <- lookup.xport.inner(file) + ans <- .Call(xport_read, file, data.info) + if (length(ans) == 1) as.data.frame(ans[[1]]) + else lapply(ans, as.data.frame) +} Added: trunk/SASxport/src/SASxport.c =================================================================== --- trunk/SASxport/src/SASxport.c (rev 0) +++ trunk/SASxport/src/SASxport.c 2007-11-01 06:01:50 UTC (rev 1202) @@ -0,0 +1,722 @@ +/* + * + * Read SAS transport data set format + * + * Copyright 1999-1999 Douglas M. Bates <ba...@st...>, + * Saikat DebRoy <sa...@st...> + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, a copy is available at + * http://www.r-project.org/Licenses/ + */ + +#include <stdio.h> +#include <string.h> +#include <R.h> +#include <Rinternals.h> +//#include "foreign.h" +#include "SASxport.h" + + +#ifdef ENABLE_NLS +#include <libintl.h> +#define _(String) dgettext ("foreign", String) +#define gettext_noop(String) (String) +#else +#define _(String) (String) +#define gettext_noop(String) (String) +#endif + + +#define HEADER_BEG "HEADER RECORD*******" +#define HEADER_TYPE_LIBRARY "LIBRARY " +#define HEADER_TYPE_MEMBER "MEMBER " +#define HEADER_TYPE_DSCRPTR "DSCRPTR " +#define HEADER_TYPE_NAMESTR "NAMESTR " +#define HEADER_TYPE_OBS "OBS " +#define HEADER_END "HEADER RECORD!!!!!!!000000000000000000000000000000 " + +#define LIB_HEADER HEADER_BEG HEADER_TYPE_LIBRARY HEADER_END +#define MEM_HEADER HEADER_BEG HEADER_TYPE_MEMBER \ + "HEADER RECORD!!!!!!!000000000000000001600000000" +#define DSC_HEADER HEADER_BEG HEADER_TYPE_DSCRPTR HEADER_END +#define NAM_HEADER HEADER_BEG HEADER_TYPE_NAMESTR \ + "HEADER RECORD!!!!!!!000000" +#define OBS_HEADER HEADER_BEG HEADER_TYPE_OBS HEADER_END +#define BLANK24 " " + +#define GET_RECORD(rec, fp, len) \ + fread((rec), sizeof(char), (size_t) (len), (fp)) + +#define IS_SASNA_CHAR(c) ((c) == 0x5f || (c) == 0x2e || \ + (0x41 <= (c) && (c) <= 0x5a)) + +#ifndef NULL +#define NULL ((void *) 0) +#endif + + +#define Two32 4294967296.0 + +static double get_IBM_double(char* c, size_t len) +{ + /* Conversion from IBM 360 format to double */ +/* + * IBM format: + * 6 5 0 + * 3 1 0 + * + * SEEEEEEEMMMM ......... MMMM + * + * Sign bit, 7 bit exponent, 56 bit fraction. Exponent is + * excess 64. The fraction is multiplied by a power of 16 of + * the actual exponent. Normalized floating point numbers are + * represented with the radix point immediately to the left of + * the high order hex fraction digit. + */ + unsigned int i, upper, lower; + /* exponent is expressed here as + excess 70 (=64+6) to accomodate + integer conversion of c[1] to c[4] */ + char negative = c[0] & 0x80, exponent = (c[0] & 0x7f) - 70, buf[4]; + double value; + char ibuf[8]; + + if (len < 2 || len > 8) + error(_("invalid field length in numeric variable")); + + /* this effectively zero-pads c: */ + memset(ibuf, 0, (size_t) 8); + memcpy(ibuf, c, len); + c = ibuf; + /* check for missing value */ + /* This isn't really right: NAs are ' ', '.', A-Z plus zero fill */ + if (c[1] == '\0' && c[0] != '\0') return R_NaReal; + /* convert c[1] to c[3] to an int */ + buf[0] = '\0'; + for (i = 1; i < 4; i++) buf[i] = c[i]; + char_to_uint(buf, upper); + /* convert c[4] to c[7] to an int */ + for (i = 0; i < 4; i++) buf[i] = c[i + 4]; + char_to_uint(buf, lower); + /* initialize the constant if needed */ + value = ((double) upper + ((double) lower)/Two32) * + pow(16., (double) exponent); + if (negative) value = -value; + return value; +} + +static int +get_nam_header(FILE *fp, struct SAS_XPORT_namestr *namestr, int length) +{ + char record[141]; + int n; + + record[length] = '\0'; + n = GET_RECORD(record, fp, length); + if(n != length) + return 0; + + char_to_short(record, namestr->ntype); + char_to_short(record+2, namestr->nhfun); + char_to_short(record+4, namestr->nlng); + char_to_short(record+6, namestr->nvar0); + memcpy(namestr->nname, record + 8, 8); + memcpy(namestr->nlabel, record + 16, 40); + memcpy(namestr->nform, record + 56, 8); + char_to_short(record+64, namestr->nfl); + char_to_short(record+66, namestr->nfd); + char_to_short(record+68, namestr->nfj); + memcpy(namestr->nfill, record + 70, 2); + memcpy(namestr->niform, record + 72, 8); + char_to_short(record+80, namestr->nifl); + char_to_short(record+82, namestr->nifd); + char_to_int(record+84, namestr->npos); + return 1; +} + +static int +get_lib_header(FILE *fp, struct SAS_XPORT_header *head) +{ + char record[81]; + int n; + + n = GET_RECORD(record, fp, 80); + if(n == 80 && strncmp(LIB_HEADER, record, 80) != 0) + error(_("file not in SAS transfer format")); + + n = GET_RECORD(record, fp, 80); + if(n != 80) + return 0; + record[80] = '\0'; + memcpy(head->sas_symbol[0], record, 8); + memcpy(head->sas_symbol[1], record+8, 8); + memcpy(head->saslib, record+16, 8); + memcpy(head->sasver, record+24, 8); + memcpy(head->sas_os, record+32, 8); + if((strrchr(record+40, ' ') - record) != 63) + return 0; + memcpy(head->sas_create, record+64, 16); + + n = GET_RECORD(record, fp, 80); + if(n != 80) + return 0; + record[80] = '\0'; + memcpy(head->sas_mod, record, 16); + if((strrchr(record+16, ' ') - record) != 79) + return 0; + return 1; +} + +static int +get_mem_header(FILE *fp, struct SAS_XPORT_member *member) +{ + char record[81]; + int n; + + n = GET_RECORD(record, fp, 80); + if(n != 80 || strncmp(DSC_HEADER, record, 80) != 0) + error(_("file not in SAS transfer format")); + + n = GET_RECORD(record, fp, 80); + if(n != 80) + return 0; + record[80] = '\0'; + memcpy(member->sas_symbol, record, 8); + memcpy(member->sas_dsname, record+8, 8); + memcpy(member->sasdata, record+16, 8); + memcpy(member->sasver, record+24, 8); + memcpy(member->sas_osname, record+32, 8); + if((strrchr(record+40, ' ') - record) != 63) + return 0; + memcpy(member->sas_create, record+64, 16); + + n = GET_RECORD(record, fp, 80); + if(n != 80) + return 0; + memcpy(member->sas_mod, record, 16); + if((strrchr(record+16, ' ') - record) != 79) + return 0; + return 1; +} + +static int +init_xport_info(FILE *fp) +{ + char record[81]; + int n; + int namestr_length; + + struct SAS_XPORT_header *lib_head; + + lib_head = Calloc(1, struct SAS_XPORT_header); + + if(!get_lib_header(fp, lib_head)) { + Free(lib_head); + error(_("SAS transfer file has incorrect library header")); + } + + Free(lib_head); + + n = GET_RECORD(record, fp, 80); + if(n != 80 || strncmp(MEM_HEADER, record, 75) != 0 || + strncmp(" ", record+78, 2) != 0) + error(_("file not in SAS transfer format")); + record[78] = '\0'; + sscanf(record+75, "%d", &namestr_length); + + return namestr_length; +} + +static int +init_mem_info(FILE *fp, char *name) +{ + int length, n; + char record[81]; + char *tmp; + struct SAS_XPORT_member *mem_head; + + mem_head = Calloc(1, struct SAS_XPORT_member); + if(!get_mem_header(fp, mem_head)) { + Free(mem_head); + error(_("SAS transfer file has incorrect member header")); + } + + n = GET_RECORD(record, fp, 80); + record[80] = '\0'; + if(n != 80 || strncmp(NAM_HEADER, record, 54) != 0 || + (strrchr(record+58, ' ') - record) != 79) { + Free(mem_head); + error(_("file not in SAS transfer format")); + } + record[58] = '\0'; + sscanf(record+54, "%d", &length); + + tmp = strchr(mem_head->sas_dsname, ' '); + n = tmp - mem_head->sas_dsname; + if(n > 0) { + if (n > 8) + n = 8; + strncpy(name, mem_head->sas_dsname, n); + name[n] = '\0'; + } else name[0] = '\0'; + + Free(mem_head); + + return length; +} + +static int +next_xport_info(FILE *fp, int namestr_length, int nvars, + int *headpad, + int *tailpad, + int *length, + int *ntype, + int *nlng, + int *nvar0, + SEXP nname, + SEXP nlabel, + SEXP nform, + int *nfl, + int *nfd, + SEXP niform, + int *nifl, + int *nifd, + int *npos) +{ + char *tmp; + char record[81]; + int i, n, nbytes, totwidth, nlength, restOfCard; + struct SAS_XPORT_namestr *nam_head; + + nam_head = Calloc(nvars, struct SAS_XPORT_namestr); + + for(i = 0; i < nvars; i++) { + if(!get_nam_header(fp, nam_head+i, namestr_length)) { + Free(nam_head); + error(_("SAS transfer file has incorrect library header")); + } + } + + *headpad = 480 + nvars * namestr_length; + i = *headpad % 80; + if(i > 0) { + i = 80 - i; + if (fseek(fp, i, SEEK_CUR) != 0) { + Free(nam_head); + error(_("file not in SAS transfer format")); + } + (*headpad) += i; + } + + n = GET_RECORD(record, fp, 80); + if(n != 80 || strncmp(OBS_HEADER, record, 80) != 0) { + Free(nam_head); + error(_("file not in SAS transfer format")); + } + + for(i = 0; i < nvars; i++) { + int nname_len = 0, nlabel_len = 0, nform_len = 0, niform_len=0; + char tmpname[41]; + + /* Variable storage type */ + ntype[i] = (int) ((nam_head[i].ntype == 1) ? REALSXP : STRSXP); + + /* Storage length */ + nlng[i] = nam_head[i].nlng; + + /* Variable number */ + nvar0[i] = nam_head[i].nvar0; + + /* Position of var in observation */ + npos[i] = nam_head[i].npos; + + /* Variable name */ + nname_len = 8; + while (nname_len && nam_head[i].nname[nname_len-1] == ' ') + nname_len--; + strncpy(tmpname, nam_head[i].nname, nname_len); + tmpname[nname_len] = '\0'; + SET_STRING_ELT(nname, i, mkChar(tmpname)); + + /* Variable label */ + nlabel_len = 40; + while (nlabel_len && nam_head[i].nlabel[nlabel_len-1] == ' ') + nlabel_len--; + strncpy(tmpname, nam_head[i].nlabel, nlabel_len); + tmpname[nlabel_len] = '\0'; + SET_STRING_ELT(nlabel, i, mkChar(tmpname)); + + /* Variable format name */ + nform_len = 8; + while (nform_len && nam_head[i].nform[nform_len-1] == ' ') + nform_len--; + strncpy(tmpname, nam_head[i].nform, nform_len); + tmpname[nform_len] = '\0'; + SET_STRING_ELT(nform, i, mkChar(tmpname)); + + /* Format length */ + nfl[i] = nam_head[i].nfl;; + + /* Format digits */ + nfd[i] = nam_head[i].nfd;; + + /* Variable iformat name */ + niform_len = 8; + while (niform_len && nam_head[i].niform[niform_len-1] == ' ') + niform_len--; + strncpy(tmpname, nam_head[i].niform, niform_len); + tmpname[niform_len] = '\0'; + SET_STRING_ELT(niform, i, mkChar(tmpname)); + + /* Format length */ + nifl[i] = nam_head[i].nifl;; + + /* Format digits */ + nifd[i] = nam_head[i].nifd;; + + } + + Free(nam_head); + + totwidth = 0; + for(i = 0; i < nvars; i++) + totwidth += nlng[i]; + + nbytes = 0; + nlength = 0; + tmp = Calloc(totwidth <= 80 ? 81 : (totwidth+1), char); + restOfCard = 0; + *tailpad = 0; + while(!feof(fp)) { + int allSpace = 1; + fpos_t currentPos; + +/* restOfCard = 80 - (ftell(fp) % 80); */ + if (fgetpos(fp, ¤tPos)) { + error(_("problem accessing SAS XPORT file")); + } + + n = GET_RECORD(tmp, fp, restOfCard); + if (n != restOfCard) { + allSpace = 0; + } else { + for (i = 0; i < restOfCard; i++) { + if (tmp[i] != ' ') { + allSpace = 0; + break; + } + } + } + if (allSpace) { + n = GET_RECORD(record, fp, 80); + if (n < 1) { + *tailpad = restOfCard; + break; + } + if(n == 80 && strncmp(MEM_HEADER, record, 75) == 0 && + strncmp(" ", record+78, 2) == 0) { + *tailpad = restOfCard; + record[78] = '\0'; + sscanf(record+75, "%d", &namestr_length); + break; + } + } + if (fsetpos(fp, ¤tPos)) { + error(_("problem accessing SAS XPORT file")); + } + + n = GET_RECORD(tmp, fp, totwidth); + if (n != totwidth) { + if (!feof(fp)) { + error(_("problem accessing SAS XPORT file")); + } + *tailpad = n; + break; + } + restOfCard = (restOfCard >= totwidth)? + (restOfCard - totwidth): + (80 - (totwidth - restOfCard)%80); + nlength++; + } + *length = nlength; + Free(tmp); + + return (feof(fp)?-1:namestr_length); +} + +/* + * get the list element named str. + */ + +static SEXP +getListElement(SEXP list, char *str) { + SEXP names; + SEXP elmt = (SEXP) NULL; + const char *tempChar; + int i; + + names = getAttrib(list, R_NamesSymbol); + + for (i = 0; i < LENGTH(list); i++) { + tempChar = CHAR(STRING_ELT(names, i)); + if( strcmp(tempChar,str) == 0) { + elmt = VECTOR_ELT(list, i); + break; + } + } + return elmt; +} + +#define VAR_INFO_LENGTH 16 + +const char *cVarInfoNames[VAR_INFO_LENGTH] = { + "headpad", + "type", + "width", + "index", + "position", + "name", + "label", + "format", + "flength", + "fdigits", + "iformat", + "iflength", + "ifdigits", + "sexptype", + "tailpad", + "length" +}; + +#define XPORT_VAR_HEADPAD(varinfo) VECTOR_ELT(varinfo, 0) +#define XPORT_VAR_TYPE(varinfo) VECTOR_ELT(varinfo, 1) +#define XPORT_VAR_WIDTH(varinfo) VECTOR_ELT(varinfo, 2) +#define XPORT_VAR_INDEX(varinfo) VECTOR_ELT(varinfo, 3) +#define XPORT_VAR_POSITION(varinfo) VECTOR_ELT(varinfo, 4) +#define XPORT_VAR_NAME(varinfo) VECTOR_ELT(varinfo, 5) +#define XPORT_VAR_LABEL(varinfo) VECTOR_ELT(varinfo, 6) +#define XPORT_VAR_FORM(varinfo) VECTOR_ELT(varinfo, 7) +#define XPORT_VAR_FLENGTH(varinfo) VECTOR_ELT(varinfo, 8) +#define XPORT_VAR_FDIGITS(varinfo) VECTOR_ELT(varinfo, 9) +#define XPORT_VAR_IFORM(varinfo) VECTOR_ELT(varinfo, 10) +#define XPORT_VAR_IFLENGTH(varinfo) VECTOR_ELT(varinfo, 11) +#define XPORT_VAR_IFDIGITS(varinfo) VECTOR_ELT(varinfo, 12) +#define XPORT_VAR_SEXPTYPE(varinfo) VECTOR_ELT(varinfo, 13) +#define XPORT_VAR_TAILPAD(varinfo) VECTOR_ELT(varinfo, 14) +#define XPORT_VAR_LENGTH(varinfo) VECTOR_ELT(varinfo, 15) + +#define SET_XPORT_VAR_HEADPAD(varinfo, val) SET_VECTOR_ELT(varinfo, 0, val) +#define SET_XPORT_VAR_TYPE(varinfo, val) SET_VECTOR_ELT(varinfo, 1, val) +#define SET_XPORT_VAR_WIDTH(varinfo, val) SET_VECTOR_ELT(varinfo, 2, val) +#define SET_XPORT_VAR_INDEX(varinfo, val) SET_VECTOR_ELT(varinfo, 3, val) +#define SET_XPORT_VAR_POSITION(varinfo, val) SET_VECTOR_ELT(varinfo, 4, val) +#define SET_XPORT_VAR_NAME(varinfo, val) SET_VECTOR_ELT(varinfo, 5, val) +#define SET_XPORT_VAR_LABEL(varinfo, val) SET_VECTOR_ELT(varinfo, 6, val) +#define SET_XPORT_VAR_FORM(varinfo, val) SET_VECTOR_ELT(varinfo, 7, val) +#define SET_XPORT_VAR_FLENGTH(varinfo, val) SET_VECTOR_ELT(varinfo, 8, val) +#define SET_XPORT_VAR_FDIGITS(varinfo, val) SET_VECTOR_ELT(varinfo, 9, val) +#define SET_XPORT_VAR_IFORM(varinfo, val) SET_VECTOR_ELT(varinfo, 10, val) +#define SET_XPORT_VAR_IFLENGTH(varinfo, val) SET_VECTOR_ELT(varinfo, 11, val) +#define SET_XPORT_VAR_IFDIGITS(varinfo, val) SET_VECTOR_ELT(varinfo, 12, val) +#define SET_XPORT_VAR_SEXPTYPE(varinfo, val) SET_VECTOR_ELT(varinfo, 13, val) +#define SET_XPORT_VAR_TAILPAD(varinfo, val) SET_VECTOR_ELT(varinfo, 14, val) +#define SET_XPORT_VAR_LENGTH(varinfo, val) SET_VECTOR_ELT(varinfo, 15, val) + + +SEXP +xport_info(SEXP xportFile) +{ + FILE *fp; + int i, namestrLength, memLength, ansLength; + char dsname[9]; + SEXP ans, ansNames, varInfoNames, varInfo; + SEXP char_numeric, char_character; + + PROTECT(varInfoNames = allocVector(STRSXP, VAR_INFO_LENGTH)); + for(i = 0; i < VAR_INFO_LENGTH; i++) + SET_STRING_ELT(varInfoNames, i, mkChar(cVarInfoNames[i])); + + PROTECT(char_numeric = mkChar("numeric")); + PROTECT(char_character = mkChar("character")); + + if(!isValidString(xportFile)) + error(_("first argument must be a file name")); + fp = fopen(R_ExpandFileName(CHAR(STRING_ELT(xportFile, 0))), "rb"); + if (!fp) + error(_("unable to open file")); + namestrLength = init_xport_info(fp); + + ansLength = 0; + PROTECT(ans = allocVector(VECSXP, 0)); + PROTECT(ansNames = allocVector(STRSXP, 0)); + + while(namestrLength > 0 && (memLength = init_mem_info(fp, dsname)) > 0) { + + PROTECT(varInfo = allocVector(VECSXP, VAR_INFO_LENGTH)); + setAttrib(varInfo, R_NamesSymbol, varInfoNames); + + SET_XPORT_VAR_TYPE(varInfo, allocVector(STRSXP, memLength)); + SET_XPORT_VAR_WIDTH(varInfo, allocVector(INTSXP, memLength)); + SET_XPORT_VAR_INDEX(varInfo, allocVector(INTSXP, memLength)); + SET_XPORT_VAR_POSITION(varInfo, allocVector(INTSXP, memLength)); + SET_XPORT_VAR_NAME(varInfo, allocVector(STRSXP, memLength)); + SET_XPORT_VAR_LABEL(varInfo, allocVector(STRSXP, memLength)); + SET_XPORT_VAR_FORM(varInfo, allocVector(STRSXP, memLength)); + SET_XPORT_VAR_FLENGTH(varInfo, allocVector(INTSXP, memLength)); + SET_XPORT_VAR_FDIGITS(varInfo, allocVector(INTSXP, memLength)); + SET_XPORT_VAR_IFORM(varInfo, allocVector(STRSXP, memLength)); + SET_XPORT_VAR_IFLENGTH(varInfo, allocVector(INTSXP, memLength)); + SET_XPORT_VAR_IFDIGITS(varInfo, allocVector(INTSXP, memLength)); + SET_XPORT_VAR_SEXPTYPE(varInfo, allocVector(INTSXP, memLength)); + SET_XPORT_VAR_HEADPAD(varInfo, allocVector(INTSXP, 1)); + SET_XPORT_VAR_TAILPAD(varInfo, allocVector(INTSXP, 1)); + SET_XPORT_VAR_LENGTH(varInfo, allocVector(INTSXP, 1)); + + namestrLength = + next_xport_info(fp, namestrLength, memLength, + INTEGER(XPORT_VAR_HEADPAD(varInfo)), + INTEGER(XPORT_VAR_TAILPAD(varInfo)), + INTEGER(XPORT_VAR_LENGTH(varInfo)), + INTEGER(XPORT_VAR_SEXPTYPE(varInfo)), + INTEGER(XPORT_VAR_WIDTH(varInfo)), + INTEGER(XPORT_VAR_INDEX(varInfo)), + XPORT_VAR_NAME(varInfo), + XPORT_VAR_LABEL(varInfo), + XPORT_VAR_FORM(varInfo), + INTEGER(XPORT_VAR_FLENGTH(varInfo)), + INTEGER(XPORT_VAR_FDIGITS(varInfo)), + XPORT_VAR_IFORM(varInfo), + INTEGER(XPORT_VAR_IFLENGTH(varInfo)), + INTEGER(XPORT_VAR_IFDIGITS(varInfo)), + INTEGER(XPORT_VAR_POSITION(varInfo)) + ); + + for(i = 0; i < memLength; i++) { + int *ntype = INTEGER(XPORT_VAR_SEXPTYPE(varInfo)); + SET_STRING_ELT(XPORT_VAR_TYPE(varInfo), i, + (ntype[i] == REALSXP) ? char_numeric : + char_character); + } + PROTECT(ans = lengthgets(ans, ansLength+1)); + PROTECT(ansNames = lengthgets(ansNames, ansLength+1)); +/* PROTECT(newAns = allocVector(VECSXP, ansLength+1)); */ +/* PROTECT(newAnsNames = allocVector(STRSXP, ansLength+1)); */ + +/* for(i = 0; i < ansLength; i++) { */ +/* SET_VECTOR_ELT(newAns, i, VECTOR_ELT(ans, i)); */ +/* SET_STRING_ELT(newAnsNames, i, STRING_ELT(ansNames, i)); */ +/* } */ +/* ans = newAns; */ +/* ansNames = newAnsNames; */ + + SET_STRING_ELT(ansNames, ansLength, mkChar(dsname)); + SET_VECTOR_ELT(ans, ansLength, varInfo); + ansLength++; + + UNPROTECT(5); + PROTECT(ans); + PROTECT(ansNames); + } + + setAttrib(ans, R_NamesSymbol, ansNames); + UNPROTECT(5); + fclose(fp); + return ans; +} + +SEXP +xport_read(SEXP xportFile, SEXP xportInfo) +{ + int i, j, k, n; + int nvar; + int ansLength, dataLength, totalWidth; + int dataHeadPad, dataTailPad; + int *dataWidth; + int *dataPosition; + SEXPTYPE *dataType; + char *record, *tmpchar, *c; + FILE *fp; + SEXP ans, names, data, dataInfo, dataName; + + ansLength = LENGTH(xportInfo); + PROTECT(ans = allocVector(VECSXP, ansLength)); + names = getAttrib(xportInfo, R_NamesSymbol); + setAttrib(ans, R_NamesSymbol, names); + + if(!isValidString(xportFile)) + error(_("first argument must be a file name")); + fp = fopen(R_ExpandFileName(CHAR(STRING_ELT(xportFile, 0))), "rb"); + if (!fp) + error(_("unable to open file")); + if (fseek(fp, 240, SEEK_SET) != 0) + error(_("problem reading SAS XPORT file '%s'"), + CHAR(STRING_ELT(xportFile, 0))); + + for(i = 0; i < ansLength; i++) { + dataInfo = VECTOR_ELT(xportInfo, i); + dataName = getListElement(dataInfo, "name"); + nvar = LENGTH(dataName); + dataLength = asInteger(getListElement(dataInfo, "length")); + SET_VECTOR_ELT(ans, i, data = allocVector(VECSXP, nvar)); + setAttrib(data, R_NamesSymbol, dataName); + dataType = (SEXPTYPE *) INTEGER(getListElement(dataInfo, "sexptype")); + for(j = 0; j < nvar; j++) + SET_VECTOR_ELT(data, j, allocVector(dataType[j], dataLength)); + + dataWidth = INTEGER(getListElement(dataInfo, "width")); + dataPosition = INTEGER(getListElement(dataInfo, "position")); + + totalWidth = 0; + for(j = 0; j < nvar; j++) + totalWidth += dataWidth[j]; + record = Calloc(totalWidth + 1, char); + + dataHeadPad = asInteger(getListElement(dataInfo, "headpad")); + dataTailPad = asInteger(getListElement(dataInfo, "tailpad")); + fseek(fp, dataHeadPad, SEEK_CUR); + + for(j = 0; j < dataLength; j++) { + n = GET_RECORD(record, fp, totalWidth); + if(n != totalWidth) { + error(_("problem reading SAS transport file")); + } + + for(k = nvar-1; k >= 0; k--) { + tmpchar = record + dataPosition[k]; + if(dataType[k] == REALSXP) { + REAL(VECTOR_ELT(data, k))[j] = + get_IBM_double(tmpchar, dataWidth[k]); + } else { + tmpchar[dataWidth[k]] = '\0'; + /* strip trailing blanks */ + c = tmpchar + dataWidth[k]; + while (c-- > tmpchar && *c == ' ') + *c ='\0'; + + SET_STRING_ELT(VECTOR_ELT(data, k), j, + (c < tmpchar) ? R_BlankString : + mkChar(tmpchar)); + } + } + } + + fseek(fp, dataTailPad, SEEK_CUR); + + Free(record); + } + UNPROTECT(1); + fclose(fp); + return ans; +} Added: trunk/SASxport/src/SASxport.h =================================================================== --- trunk/SASxport/src/SASxport.h (rev 0) +++ trunk/SASxport/src/SASxport.h 2007-11-01 06:01:50 UTC (rev 1202) @@ -0,0 +1,86 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, a copy is available at + * http://www.r-project.org/Licenses/ + */ + +/* + * This file is derived from code in the SAS Technical Support + * document TS-140 "The Record Layout of a Data Set in SAS Transport + * (XPORT) Format" available as + * http://ftp.sas.com/techsup/download/technote/ts140.html + */ + +#ifndef SASEXPORT_H +#define SASEXPORT_H + +#include <string.h> /* for memcpy and memset */ +#include "swap_bytes.h" + +/* double cnxptiee(double from, int fromtype, int totype); */ + + + +struct SAS_XPORT_header { + char sas_symbol[2][8]; /* should be "SAS " */ + char saslib[8]; /* should be "SASLIB " */ + char sasver[8]; + char sas_os[8]; + char sas_create[16]; + char sas_mod[16]; +}; + +struct SAS_XPORT_member { + char sas_symbol[8]; + char sas_dsname[8]; + char sasdata[8]; + char sasver[8]; + char sas_osname[8]; + char sas_create[16]; + char sas_mod[16]; +}; + +struct SAS_XPORT_namestr { + short ntype; /* VARIABLE TYPE: 1=NUMERIC, 2=CHAR */ + short nhfun; /* HASH OF NNAME (always 0) */ + short nlng; /* LENGTH OF VARIABLE IN OBSERVATION */ + short nvar0; /* VARNUM */ + char nname[8]; /* NAME OF VARIABLE */ + char nlabel[40]; /* LABEL OF VARIABLE */ + char nform[8]; /* NAME OF FORMAT */ + short nfl; /* FORMAT FIELD LENGTH OR 0 */ + short nfd; /* FORMAT NUMBER OF DECIMALS */ + short nfj; /* 0=LEFT JUSTIFICATION, 1=RIGHT JUST */ + char nfill[2]; /* (UNUSED, FOR ALIGNMENT AND FUTURE) */ + char niform[8]; /* NAME OF INPUT FORMAT */ + short nifl; /* INFORMAT LENGTH ATTRIBUTE */ + short nifd; /* INFORMAT NUMBER OF DECIMALS */ + int npos; /* POSITION OF VALUE IN OBSERVATION */ + char rest[52]; /* remaining fields are irrelevant */ +}; + +#ifdef WORDS_BIGENDIAN + +#define char_to_short(from, to) memcpy(&to, from, 2) +#define char_to_int(from, to) memcpy(&to, from, 4) +#define char_to_uint(from, to) memcpy(&to, from, 4) + +#else + +#define char_to_short(from, to) memcpy(&to, from, 2); reverse_short(to); +#define char_to_int(from, to) memcpy(&to, from, 4); reverse_int(to); +#define char_to_uint(from, to) memcpy(&to, from, 4); reverse_uint(to); + +#endif /* WORDS_BIGENDIAN */ + +#endif /* SASEXPORT_H */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-11-01 06:44:27
|
Revision: 1210 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1210&view=rev Author: warnes Date: 2007-10-31 23:44:25 -0700 (Wed, 31 Oct 2007) Log Message: ----------- Update TODO file Modified Paths: -------------- trunk/SASxport/TODO trunk/SASxport/inst/ChangeLog Modified: trunk/SASxport/TODO =================================================================== --- trunk/SASxport/TODO 2007-11-01 06:43:24 UTC (rev 1209) +++ trunk/SASxport/TODO 2007-11-01 06:44:25 UTC (rev 1210) @@ -1,6 +1,3 @@ - Write test routines for very large files, particulary very large files with columns contiaining almost all missing values. -- Test that created files are properly read by SAS, particulary when - the SAS version and OS version are set to the default values I've - provided. Modified: trunk/SASxport/inst/ChangeLog =================================================================== --- trunk/SASxport/inst/ChangeLog 2007-11-01 06:43:24 UTC (rev 1209) +++ trunk/SASxport/inst/ChangeLog 2007-11-01 06:44:25 UTC (rev 1210) @@ -1,3 +1,111 @@ +2007-11-01 06:43 warnes + + * man/SASxport-package.Rd, man/label.Rd, man/read.xport.Rd, + man/toSAS.Rd, man/write.xport.Rd: Update to match changes to + functions + +2007-11-01 06:42 warnes + + * DESCRIPTION: Update to match package changes + +2007-11-01 06:42 warnes + + * tests/Alfalfa_Test.Rout.save, tests/TestUnnamedComponents.R, + tests/TestUnnamedComponents.Rout.save, tests/Theoph.Rout.save, + tests/cars.Rout.save, tests/testDates.Rout.save, + tests/testNegative.Rout.save, tests/testNumeric.R, + tests/testNumeric.Rout.save, tests/test_fields.Rout.save, + tests/xport.Rout.save, tests/xxx.R, tests/xxx.Rout.save: Update + stored test output to match package changes + +2007-11-01 06:41 warnes + + * inst/NEWS: Update for new release + +2007-11-01 06:16 warnes + + * NAMESPACE: Remove dependency on foreign + +2007-11-01 06:15 warnes + + * src/ieee2ibm.c, src/init.c, src/swap_bytes.h: Copy code from + foreign for lookup.xport() and read.xport(), extend + lookup.xport() to show information about SAS format and iformat + +2007-11-01 06:14 warnes + + * R/SASformat.R, R/SASiformat.R, R/formats.R, R/fstr.R, + R/iformat.R, R/lookup.xport.R, R/make.formats.R, R/read.xport.R, + R/toSAS.R, R/write.xport.R: - Use of the attribute named 'format' + caused problems with chron + objects. Consequently, the format information is now stored in + the + 'SASformat' attribute. For consistency, the input format + information + is now stored in the 'SASiformat' attribute. + + - The functions for extracting and setting the format and iformat + information have been renamed to 'SASformat' and 'SASiformat', + etc. + + - In order to properly handle SAS format information, we now use + a + locally modified version of foreign::lookup.xport and + foreign::read.xport. + + - Various typo corrections + + - Creation of a new function fstr() to generate sas format name + strings + using name, length, and digits information. + + - Addion of a toSAS method for chron() objects + +2007-11-01 06:01 warnes + + * R/xport.R, src/SASxport.c, src/SASxport.h: Copy code from foreign + for lookup.xport() and read.xport(), extend lookup.xport() to + show information about SAS format and iformat + +2007-11-01 05:59 warnes + + * R/importConvertDateTime.R: Improve handling of SAS data and time + formats, simplify code + +2007-10-29 15:37 warnes + + * DESCRIPTION, R/xport.numeric.R, inst/ChangeLog, src/ibm2ieee.c, + src/ieee2ibm.c, tests/testNegative.R: Fixes to correct handling + storage of negative numbers + +2007-10-29 15:35 warnes + + * R/zzz.R: Belatedly commit change to startup message to give path + to SASxport product page rather than contact page + +2007-10-29 15:34 warnes + + * src/reverse.c: Comment out debugging message in reverse() + +2007-10-29 15:32 warnes + + * tests/Alfalfa_Test.Rout.save, + tests/TestUnnamedComponents.Rout.save, tests/Theoph.Rout.save, + tests/cars.Rout.save, tests/testDates.Rout.save, + tests/test_fields.Rout.save, tests/xport.Rout.save, + tests/xxx.Rout.save: Commit changes to stored output to match + changed package load message + +2007-10-22 02:24 warnes + + * branches/GenerateFORMATSfromFactorObjects/SASxport/DESCRIPTION, + trunk/MSOfficeUtil/DESCRIPTION, trunk/RMCMC/DESCRIPTION, + trunk/Rlsf/DESCRIPTION, DESCRIPTION, trunk/bwRF/DESCRIPTION, + trunk/exp.ssize/DESCRIPTION, trunk/fork/DESCRIPTION, + trunk/gdata/DESCRIPTION, trunk/gmodels/DESCRIPTION, + trunk/gplots/DESCRIPTION, trunk/gregmisc/DESCRIPTION, + trunk/ssize/DESCRIPTION: Clarify GPL version + 2007-10-02 22:34 warnes * inst/ChangeLog, tests/Alfalfa_Test.Rout.save, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2007-11-05 15:25:42
|
Revision: 1220 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1220&view=rev Author: warnes Date: 2007-11-05 07:25:38 -0800 (Mon, 05 Nov 2007) Log Message: ----------- Remove extraneous ';' characters after function closing brace Modified Paths: -------------- trunk/SASxport/DESCRIPTION trunk/SASxport/inst/NEWS trunk/SASxport/src/writeSAS.c Modified: trunk/SASxport/DESCRIPTION =================================================================== --- trunk/SASxport/DESCRIPTION 2007-11-02 19:32:24 UTC (rev 1219) +++ trunk/SASxport/DESCRIPTION 2007-11-05 15:25:38 UTC (rev 1220) @@ -1,7 +1,7 @@ Package: SASxport Type: Package Title: Read and Write SAS XPORT Files -Version: 1.2.0 +Version: 1.2.1 Date: 2007-11-01 Description: This package provides functions for reading, listing the contents of, and writing SAS xport format files. Modified: trunk/SASxport/inst/NEWS =================================================================== --- trunk/SASxport/inst/NEWS 2007-11-02 19:32:24 UTC (rev 1219) +++ trunk/SASxport/inst/NEWS 2007-11-05 15:25:38 UTC (rev 1220) @@ -1,6 +1,15 @@ -Version 1.2.0 +Version 1.2.1 2007-11-05 ------------------------- +Other: + +- Correct warning message due to extraneous ';' charcters after + function closing braces. + + +Version 1.2.0 2007-11-01 +------------------------- + New Features: - SAS format and iformat information is now accessed via 'SASformat()' Modified: trunk/SASxport/src/writeSAS.c =================================================================== --- trunk/SASxport/src/writeSAS.c 2007-11-02 19:32:24 UTC (rev 1219) +++ trunk/SASxport/src/writeSAS.c 2007-11-05 15:25:38 UTC (rev 1220) @@ -184,7 +184,7 @@ raw_buffer_used = 320; return; -}; +} void fill_namestr_header( @@ -206,7 +206,7 @@ raw_buffer_used = 80; return; -}; +} void fill_namestr( int *isChar, /* Bool: Is this a character varible */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2008-02-29 15:40:13
|
Revision: 1245 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1245&view=rev Author: warnes Date: 2008-02-29 07:40:11 -0800 (Fri, 29 Feb 2008) Log Message: ----------- Update for release 1.2.3 Modified Paths: -------------- trunk/SASxport/DESCRIPTION trunk/SASxport/inst/ChangeLog trunk/SASxport/inst/NEWS Modified: trunk/SASxport/DESCRIPTION =================================================================== --- trunk/SASxport/DESCRIPTION 2008-02-29 15:37:16 UTC (rev 1244) +++ trunk/SASxport/DESCRIPTION 2008-02-29 15:40:11 UTC (rev 1245) @@ -1,8 +1,8 @@ Package: SASxport Type: Package Title: Read and Write SAS XPORT Files -Version: 1.2.2 -Date: 2007-11-07 +Version: 1.2.3 +Date: 2008-02-29 Description: This package provides functions for reading, listing the contents of, and writing SAS xport format files. The functions support reading and writing of either Modified: trunk/SASxport/inst/ChangeLog =================================================================== --- trunk/SASxport/inst/ChangeLog 2008-02-29 15:37:16 UTC (rev 1244) +++ trunk/SASxport/inst/ChangeLog 2008-02-29 15:40:11 UTC (rev 1245) @@ -1,3 +1,12 @@ +2008-02-29 15:37 warnes + + * [r1244] man/write.xport.Rd: Correct typo in write.xport man page + +2007-11-09 22:45 warnes + + * [r1227] inst/ChangeLog, inst/NEWS: Update NEWS and ChangeLog for + 1.2.2 + 2007-11-09 19:59 warnes * [r1226] src/ibm2ieee.c, src/ieee2ibm.c: Apply patches to fix Modified: trunk/SASxport/inst/NEWS =================================================================== --- trunk/SASxport/inst/NEWS 2008-02-29 15:37:16 UTC (rev 1244) +++ trunk/SASxport/inst/NEWS 2008-02-29 15:40:11 UTC (rev 1245) @@ -1,3 +1,11 @@ +Version 1.2.3 2008-02-29 +------------------------ + +Bug fixes: + +- Fix typo in manual page for write.xport() reported by Yinlai Meng. + + Version 1.2.2 2007-11-09 ------------------------ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |