[R] sas.get problem

Nordlund, Dan (DSHS/RDA) NordlDJ at dshs.wa.gov
Wed Apr 11 23:34:17 CEST 2007


> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of John Kane
> Sent: Wednesday, April 11, 2007 11:30 AM
> To: Cody_Hamilton at edwards.com
> Cc: R R-help
> Subject: Re: [R] sas.get problem
> 
> 
<<<snip>>>
> 
> Current state of play:
> Files : SAS 9.x
> 
> formea1.sas7bdat
> formea2.sas7bdat
> formats.sas7bcat
> 
> I notice that the formats.sas7bcat is drastically
> different from the sas.bdat
> icons.
> 
> We seem to  be making some progress even if the data
> file still has not loaded.
> 
> In the ammended sas.get condition I get an error
> object ".R." not found.
> I hope this is not an Hmisc object.
> 
> Thanks
> 
> 
> Run with Hmisc
> 
> mydata <- sas.get(library="F:/sas", mem="formea1",
>              format.library="F:/sas",
>   sasprog = '"C:Program Files/SAS/SAS 9.1/sas.exe"')
>            
> Error in sas.get(library = "F:/sas", mem = "formea1",
> format.library = "F:/sas",  :
>         SAS job failed with status -1
> In addition: Warning message:
> "\"C:Program not found
> 

The warning here is due to wrapping the sasprog argument in single and double quotes.  Sometimes you need to do this in R when trying to run a command using system() under Windows.  However, sas.get() uses the function shQuote() to wrap Windows system calls in double quotes and escapes any internal double quotes with "\".  You can see the escape character in the warning message above.  If you remove the single quotes the warning should disappear.  

> 
> Run with modified sas.get (Hmisc not loaded)
> 
> Error in sas.get(library = "F:/sas", mem = "formea1",
> format.library = "F:/sas",  :
>         object ".R." not found
> 

Actually, you should load Hmisc using library(Hmisc) and then source in your corrected sas.get() function.  Then execute the following call

mydata <- sas.get(library="F:/sas", mem="formea1",
              format.library="F:/sas",
   sasprog = "C:/Program Files/SAS/SAS 9.1/sas.exe") #no single quotes

This assuming that your sas dataset and formats.sas7bcat are in F:\SAS and the SAS executable is in the specified directory on the c: drive of the machine you are running this on.

Hope this is helpful,

Dan


Daniel J. Nordlund
Research and Data Analysis
Washington State Department of Social and Health Services
Olympia, WA  98504-5204



More information about the R-help mailing list