| Date: | Mon, 25 Mar 2002 09:51:58 -0500 |
| Reply-To: | "David L. Ward" <dward@SASHELP.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | "David L. Ward" <dward@SASHELP.COM> |
| Subject: | Re: Portable SAS code.. |
| In-Reply-To: | <a7nccv$cfh$1@slb3.atl.mindspring.net> |
| Content-Type: | text/plain; charset="iso-8859-1" |
I have initialized a 1-byte string at the start of my applications to the
proper directory delimiter based on the operating system. You can scan the
physical path of the WORK libname to determine which delimiter is used, then
in your code something like:
i=1;
work=pathname(work);
do while(i<=length(work) and dirDlm='');
if substr(work,i,1) in ('/' '\') then dirDlm=substr(work,i,1);
i=i+1;
end;
rc=filename('tmp',pathname('work')||dirDlm||'out.txt');
(untested right now)
Or I suppose you could write a method that would translate the file path
according to the current OS and code them all the same.
HTH
David Ward
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On Behalf Of Richard
A. DeVenezia
Sent: Monday, March 25, 2002 9:30 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Portable SAS code..
"Alastair Nicol" <calaban.madness@BLUEYONDER.CO.UK> wrote in message
news:T59cc8bb40fac1785ec0c4@pcow034o.blueyonder.co.uk...
> Hi,
> i'm writting a Python / SAS app which i would like to run on both
windows
> and unix (min). The SCL code works fine under windows, but i've never
used
> SAS under Unix (and havnt got sas for linux to test!)
>
> 1. whats the best way round the "\" "/" problem (or does SAS do this for
> you). best i can up with is if os=unix then sep=''/';else sep="\".
> 2. any other issues (there are NO frame entries, its batch SCL).
>
> all nums are 8 in length (only ints being used anyway)
> the scl source is already saved as text files so cat problems arnt an
issue.
> ive a macro to compile this into a catalog
>
> also, do SAS TCP/IP sockets (filename and fopen/ fgets etc) work the
same
> way under unix. i assume they do.
>
> Thanks, Alastair
In SAS Version 6.12 and 8 for Windows, SAS will auto-translate directory
separators.
data _null_;
file 'c:/temp/xyz.lst';
put 'abc';
run;
will show in the log
NOTE: The file 'c:/temp/xyz.lst' is:
File Name=c:\temp\xyz.lst,
RECFM=V,LRECL=256
NOTE: 1 record was written to the file 'c:/temp/xyz.lst'.
The minimum record length was 3.
The maximum record length was 3.
NOTE: DATA statement used:
real time 0.01 seconds
cpu time 0.01 seconds
So, as long as you keep things to relative paths, you won't have to worry
about anything. If you use absolute paths you have to worry about how to
indicate the root.
--
Richard A. DeVenezia
Need long HTML Titles and Footnotes ?
http://www.devenezia.com/downloads/sas/macros/index.html#js
|