[R] sas.get problem : the saga continues.

Nordlund, Dan (DSHS/RDA) NordlDJ at dshs.wa.gov
Fri Apr 13 23:53:08 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: Friday, April 13, 2007 1:37 PM
> To: R R-help
> Subject: Re: [R] sas.get problem : the saga continues.
> 
> 
> #Continuing my sas.get saga.  Hmisc has been been
> updated however I am still
> getting the same problem. I seem to have aa SAS
> problem  as well as
>  an R problem.  There seems to be something dodgy in
> the SAS data or
> format files since SAS will not read the file unless I
> use
>  LIBNAME library = 'F:\testsas'
>  Something like
>  LIBNAME dd1 = 'F:\testsas'
>  will not work and it should whereas Libname
> dd1="C:\Temp\testsas"  does.
>  
> However I still cannot get sas.get to read a simple
> file which does work with
> LIBNAME dd1 = 'F:\testsas' .  Can anyone see if I am
> misreading the Help or
> making some kind of stupid typing mistake? I also have
> tried running it on the
> C drive with no luck. Thanks
> 
> Windows XP, R 2.4.1
> 
>  ###### EXAMPLE  #########
>  #### SAS PROGRAM for simple file.  ###
> libname  LIBRARY 'F:\testsas';
> proc format library= LIBRARY;
> value catfmt 1 = "Siam"
>              2 = "Persian"
>              3 = "Cougar";
> value dogfmt 1 = "Lab"
>              2 = "Collie"
>              3 = "Coyote";
> run;
> data library.animals;
>    input cat dog;
>    datalines;
> 1 3
> 2 2
> 3 1
> ;
> 
> Data LIBRARY.doms;
>  set LIBRARY.Animals ;
>  format cat catfmt. dog  dogfmt.;
>  proc freq;
>  run;
>  
> #####
> #   Apply sas.get
> 
> library(Hmisc)
> mydata <- sas.get(library="F:/testsas", mem="doms",
>              format.library="F:/testsas",
>   sasprog = '"C:/Program Files/SAS/SAS 9.1/sas.exe"')
> 
> RESULTS
> 
> > library(Hmisc)
> > mydata <- sas.get(library="C:/Temp/testsas",
> mem="doms",
> +              format.library="C:/Temp/testsas",
> +   sasprog = '"C:/Program Files/SAS/SAS
> 9.1/sas.exe"')
> The filename, directory name, or volume label syntax
> is incorrect.
> Error in sas.get(library = "C:/Temp/testsas", mem =
> "doms", format.library = "C:/Temp/testsas",  :
>         SAS job failed with status 1
> In addition: Warning message:
> 'cmd' execution failed with error code 1 in:
> shell(cmd, wait = TRUE, intern = output)

John,

You may have missed my earlier post about this.  The problem you are having with SAS is the value you are passing in the sasprog parameter.  You need to drop the single quotes, like the following 

sasprog = "C:/Program Files/SAS/SAS 9.1/sas.exe"

sas.get() calls a function, shQuote(), which wraps the program name in double quotes and then escapes the double quotes you are passing, which messes up the program name that Windows sees.

I don't understand exactly what problem you are having with the library names.  If I take your code and replace every instance of LIBRARY (in all caps) with dd1, your program runs just fine on my WinXP Pro system.  If changing the sasprog parameter value as above doesn't work, write back to the R-help with the errors you get and someone (maybe even me :-) should be able to help.

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