Another way to read an Ingres table from SAS version 9
SAS Version 9 doesn't support Access to Ingres, so we have to use a Connect session to version 8.
options autosignon;
rsubmit sascmd='sas8' remote=newton persist=yes;
%sysrput v8worklib = %SYSFUNC(pathname(work));
libname ocnrates ingres database="%SYSGET(MT_RPT_OCNRATES)"
access=readonly;
proc sql stimer;
create table cnvrsn_fctr_typ_r as
select cnvrsn_fctr_typ_cd,
cnvrsn_fctr_typ_desc
from ocnrates.cnvrsn_fctr_typ_r
where cnvrsn_fctr_typ_cd not in ('BYPAS', 'FACIL')
order by cnvrsn_fctr_typ_cd;
quit;
endrsubmit;
libname work8 v8 "&V8WORKLIB.";
proc copy in=work8 out=work constraint=yes index=yes datecopy move
clone;
select cnvrsn_fctr_typ_r;
run;
rsubmit;
proc datasets;
run; quit;
endrsubmit;
libname work8 clear;
signoff;
"options autosignon" tells SAS to start the remote session with the rsubmit, without an explicit signon command.
"rsubmit sascmd='sas8' remote=newton persist=yes" tells SAS to start a SAS v8 session on Newton, and not to close the session after the rsubmit block has finished executing. This keeps the remote work library available until a signoff command is executed.
"%sysrput v8worklib = %SYSFUNC(pathname(work))" tells SAS to create a macro variable V8WORKLIB in the local session whose value is the path to the work library of the remote session.
We then write some data to that work library.
"libname work8 v8 "&V8WORKLIB.";" creates a libref in the local session that points to the remote session's work library, where the results of the code we just executed are stored.
PROC COPY moves the selected tables from the remote library to the local library. The work library doesn't have to be WORK, of course. The other options are things I think we would usually want. For moving ordinary data sets, PROC COPY is probably better than PROC MIGRATE.
The next rsubmit block is only there to show that you can submit more remote code to execute; after the first time you on't have to specify any options, and the last active session will be used.
Finally, we clear the libname and close the remote session. If you don't do this explicitly, it will happen automatically when the job ends.

0 Comments:
Post a Comment
<< Home