/* This file contains examples from SAS/CONNECT Software: */ /* Usage and Reference, Version 6, Second Edition, 1994 */ */ /* NOTE: You must supply values for variables in some examples */ /* as indicated by comments preceding the variables. Variables */ /* appear as single words or hyphenated strings */ /* **** CONTENTS OF THIS FILE ********************************** Example 1. Compute Services: Saving Remote Processing Results on the Local Host (p. 20) Example 2. Compute Services: Administration Tasks for Remote Data Sets (p. 20) Example 3. Compute Services: Using Remote Applications from a Local Host (p. 21) Example 4. Compute Services: Remote Graphics Processing (p. 22) Example 5. RSPT Services: Querying a Table in DB2 (p. 27) Example 6. RSPT Services: Subsetting Remote SAS Data (p. 28) Example 7. RLS: Accessing Remote Data to Print a List of Reports (p. 35) Example 8. RLS: Accessing Remote Data with the WHERE Statement (p. 36) Example 9. RLS: Updating Remote Data (p. 36) Example 10. RLS: An SCL Program with the WHERE Statement (p. 37) Example 11. RLS: Updating a Remote Data Set by Applying a Local Transaction Data Set (p. 37) Example 12. RLS: Subsetting Remote Data for Local Processing and Display (p. 39) Example 13. Data Transfer Services: Transferring Data with WHERE Statements (p. 42) Example 14. Data Transfer Services: Transferring Specific Member Types with SELECT or EXCLUDE (p. 42) Example 15. Data Transfer Services: Transferring Specific Catalog Entry Types (p. 43) Example 16. Data Transfer Services: Transferring Data with Data Set Options and Attributes (p. 45) Example 17. Data Transfer Services: Distributing a .EXE File from the Remote Host to Multiple Local Hosts (p. 45) Example 18. Data Transfer Services: Uploading a Catalog with Graphics Output (p. 47) Example 19. Data Transfer Services: Downloading a Partitioned Data Set from an MVS Host (p. 47) Example 20. Data Transfer Services: Combining Data from Multiple Remote Sessions (p. 49) Example 21. Compute Services and Data Transfer Services Combined (p. 53) Example 22. Compute Services and Data Transfer Services Combined (p. 55) Example 23. Compute Services and Data Transfer Services Combined: Macro Capabilities (p. 56) Example 24. RLS and UPLOAD/DOWNLOAD Combined: Distribution of Reports Over a Network (p. 58) Example 25. Script for EHLLAPI Connections (p. 72) Example 26. Script for TCP/IP Connections (p. 75) Example 27. Automatic Logon (p. 79) Example 28. Manual Logon (p. 82) Example 29. Locating and Storing Sample Script Files with SCL Functions (p. 85) Example 30. Sample Script Connecting to VSE with a Protocol Converter (p. 153) Example 31. A Sample Keyboard Translation Table, CUTMODE.XLT (p. 306) Example 32. Micro-to-Host Link Automated Remote Processing (p. 312) **** END OF CONTENTS LISTING ************************************* */ /* Example 1. Compute Services: Saving Remote */ /* Processing Results on the Local Host (p. 20) */ proc printto new print='contents.mvs'; run; rsubmit; /* CONTENTS will produce a list of all */ /* data files in the library MVSLIB,*/ /* as well as supply variable */ /* information on each data set. */ proc contents data=mvslib._all_; run; endrsubmit; proc printto; run; /* =================================================== */ /* Example 2. Compute Services: Administration */ /* Tasks for Remote Data Sets (p. 20) */ rsubmit; proc datasets lib=mvslib; /* add an ALTER password to remote data set TASKLIST */ modify tasklist (alter=sesame) ; run; /* Maintain a week's worth of backup copies of */ /* data set CURRENT. */ age current backup1 - backup7; run; quit; endrsubmit; /* =================================================== */ /* Example 3. Compute Services: Using Remote */ /* Applications from a Local Host (p. 21) */ /* SAS/STAT Software Example */ rsubmit; /* The output from GLM is returned to the */ /* local SAS listing. */ proc glm data=main.employee outstat=results; model sex = income ; run; /* Use GLM's output data set RESULTS to */ /* create macro variables F_STAT and */ /* PROB--containing the F-statistic */ /* and PROB > F respectively. */ data _null_; set results(where=(_type_= 'SS1')); call symput('f_stat',f); call symput('prob',prob); run; /* Create macro variables in the local */ /* session which contain the two */ /* statistics of interest. */ %sysrput f_stat=&f_stat; %sysrput prob=&prob; endrsubmit; /* Sorting Example */ rsubmit; /* indicate to the remote host that the HOST sort */ /* utility should be used with PROC SORT. */ /* Ask SORT to subset out only those observations */ /* of interest. */ options sortpgm=host; proc sort data=mvslib.inventry out=nostock; where status='Out-of-stock'; by orderdt stockid ; run; /* output the results; local side will receive */ /* the listing from PRINT. */ title 'Inventory that is currently Out of Stock'; title2 'by Reorder Date'; proc print data=nostock; by orderdt; run; endrsubmit; /* =================================================== */ /* Example 4. Compute Services: Remote Graphics */ /* Processing (p. 22) */ rsubmit &rsessid; proc sort data=master.bgreserv out=tmp; by origin rntltype; run; proc summary data=tmp vardef=n noprint; by origin rntltype; output out=tmprtype; run; goptions dev=grlink ftitle=centx ftext=simplex htitle=2; title 'Rental Types by Franchise'; pattern value=solid color=blue; axis1 label=('Franchise') order=('ATLANTA' 'CHICAGO' 'LOS ANGELES' 'NEW YORK' 'TORONTO') width=3; axis2 label=none width=3; axis3 label=none order=0 to 1000 by 100 width=3; proc gchart data=tmprtype; label rntltype='00'x; label origin='00'x; hbar rntltype / frame sumvar= _freq_ maxis=axis2 raxis=axis3 minor=0 nostats group=origin gaxis=axis1 discrete;run;quit; endrsubmit; /* =================================================== */ /* Example 5. RSPT Services: Querying a Table */ /* in DB2 (p. 27) */ /* From an MVS SAS session to DB2 */ connect to db2 (ssid=db2p); select * from connection to db2 (select name, creator, colcount from sysibm.systables where creator='THOMPSON' or creator='JONES'); /* From an OS/2 SAS session to remote */ /* MVS SAS session to DB2 */ connect to remote (server=mvs dbms=db2 dbmsarg=(ssid=db2p)); select * from connection to remote (select name, creator, colcount from sysibm.systables where creator='THOMPSON' or creator='JONES'); /* From an OS/2 SAS session to remote */ /* MVS SAS session to DB2 with AS alias clause */ connect to remote as db2 (server=mvs dbms=db2 dbmsarg=(ssid=db2p)); select * from connection to db2 (select name, creator, colcount from sysibm.systables where creator='THOMPSON' or creator='JONES'); /* =================================================== */ /* Example 6. RSPT Services: Subsetting */ /* Remote SAS Data (p. 28) */ /* Creating a personal view */ /* NOTE: you must supply a value for server-name */ libname servlib '/dept/sales/revenue' server=server-name; connect to remote (server=server-name); create view mylib.sales93 as select * from connection to remote (select customer, sum(amount) as amount from servlib.sales where year=1993 and salesrep='L. PETERSON' group by customer order by customer); /* Creating a shared view */ libname servlib '/dept/sales/revenue' server=server-name; connect to remote (server=server-name); execute by remote (create view servlib.cust93 as select customer, sum(amount) as amount from sales where year=1993 group by customer); /* =================================================== */ /* Example 7. RLS: Accessing Remote Data to */ /* Print a List of Reports (p. 35) */ signon rempc; /* define remote library to local session */ libname reports REMOTE 'd:\\prod\\reports' server=rempc; data _null_; set reports.request; if (copy = "Y") then do; put "Report " rptname " has been requested"; end; /* =================================================== */ /* Example 8. RLS: Accessing Remote Data with */ /* the WHERE Statement (p. 36) */ signon rempc; /* define remote library to local session */ libname reports REMOTE 'd:\\prod\\reports' server=rempc; /* use WHERE statement to filter unneeded observations */ data _null_; set reports.request; where copy = "Y"; put "Report " rptname " has been requested"; end; /* =================================================== */ /* Example 9. RLS: Updating Remote Data (p. 36) */ /* define remote human resources library to local SAS */ /* session */ /* NOTE: you must supply a value for mvs-serverid */ libname rlib REMOTE 'hrs.emp.data' server=mvs-serverid; /* execute local fsedit to update employee data set */ /* that exists on MVS. */ proc fsedit data=rlib.employee; run; /* =================================================== */ /* Example 10. RLS: An SCL Program with the */ /* WHERE Statement (p. 37) */ signon mvs; /* define remote library to local SAS session */ libname master REMOTE "hq.prod.data" server=mvs; /* open remote Headquarters data base */ rdsid = open("master.reserv", 'u'); /* build and apply where clause to speed up retrieval */ wherecls = "resnum=" || "'" || resnum || "'"; rc = where(rdsid, wherecls); call set(rdsid); rc = fetchobs(rdsid, 1); /* =================================================== */ /* Example 11. RLS: Updating a Remote Data Set by */ /* Applying a Local Transaction Data Set (p. 37) */ signon; rsubmit; data sasuser.sbudget; length category $ 9; input category $ balance; format balance dollar10.2; datalines; utilities 500 mortgage 8000 telephone 1000 food 3000; run; endrsubmit; data bills; length category $ 9; input category $ billamt; datalines; utilities 45.83 mortgage 649.95 food 68.21; run; libname rlslib slibref=sasuser server=&rsession; data rlslib.sbudget; modify rlslib.sbudget bills; by category; balance=balance-billamt; run; data _null_; set rlslib.sbudget; put 'Balance for ' category @25 'is: ' balance; run; signoff; /* =================================================== */ /* Example 12. RLS: Subsetting Remote Data */ /* for Local Processing and Display (p. 39) */ init: submit continue; libname remote '/u/user1/reservations' server=srv1; proc sort data=remote.reservc(keep=company origin where=(origin='ATLANTA')) out=tmp; by company; run; proc summary data=tmp vardef=n noprint; by company; output out=tmp2; run; proc printto new print=work.view.report.source;run; proc report ls=74 ps=85 split="/" HEADLINE HEADSKIP CENTER NOWD; column ("Totals" "" "" "" company _freq_); define company / group format=$40. width=40 spacing=2 left "Company"; define _freq_ / sum width = 14 spacing=2 right "# Reservations"; rbreak after /ol dul skip summarize color=cyan;run; proc printto print=print;run; endsubmit; call execcmdi('notepad work.view.report.source; color back blue;'); _status_ = 'H'; return; main: return; term: return; /* =================================================== */ /* Example 13. Data Transfer Services: Tranferring */ /* Data with WHERE Statements (p. 42) */ proc upload data=labeled out=new; where lname < 'K'; run; /* =================================================== */ /* Example 14. Data Transfer Services: */ /* Transferring Specific Member Types with */ /* SELECT or EXCLUDE (p. 42) */ /* MEMTYPE= in the PROC UPLOAD Statement */ proc upload inlib=this outlib=that memtype=(data catalog); /* MEMTYPE= in the EXCLUDE Statement */ proc upload inlib=work outlib=work mt=all; exclude z4-z7 / memtype=data; run; /* MEMTYPE= in the SELECT Statement */ proc download inlib=work outlib=local; select names junk media(data) / memtype=cat; run; /* =================================================== */ /* Example 15. Data Transfer Services: Transferring */ /* Specific Catalog Entry Types (p. 43) */ /* Using the ENTRYTYPE= Option in the */ /* PROC UPLOAD Statement */ proc upload incat=work.cat outcat=work.upcat et=list; run; /* Using the ENTRYTYPE= Option in the */ /* EXCLUDE Statement for DOWNLOAD */ proc download incat=remote.formats outcat=local.outfmt; exclude xyz grades / entrytype=format; run; /* Using the ENTRYTYPE= Option in the */ /* SELECT Statement for UPLOAD */ proc upload incat=formats outcat=outfmt; select xyz.format grades abc (et=format) / et=infmt; select a b /et=cbt; run; /* Using the ENTRYTYPE= Option in Two */ /* SELECT Statements */ proc download incat=rhost.finance outcat=lhost.finance et=grseg; select income expense; select group1; run; /* =================================================== */ /* Example 16. Data Transfer Services: */ /* Transferring Data with Data Set Options */ /* and Attributes (p. 45) */ proc download data=idx(drop=sex) index=no; run; /* =================================================== */ /* Example 17. Data Transfer Services: */ /* Distributing a .EXE File from the Remote */ /* Host to Multiple Local Hosts (p. 45) */ /* UPLOAD */ /* NOTE: You must supply a value for remote-host-file */ filename rfile 'remote-host-file '; proc upload infile='a:\program.exe' outfile=rfile binary; run; /* DOWNLOAD */ filename rfile 'remote-host-file'; proc download infile=rfile outfile='program.exe' binary; run; /* =================================================== */ /* Example 18. Data Transfer Services: Uploading */ /* a Catalog with Graphics Output (p. 47) */ proc upload incat=rhost.finance outcat=rhost.finance et=grseg; select (income expense); select group1; run; =================================================== /* Example 19. Data Transfer Services: */ /* Downloading a Partitioned Data Set from */ /* an MVS Host (p. 47) */ filename inpds 'myhost.sas.programs' shr; filename gen 'programs.allsas' lrecl=80 blksize=6160 disp=(new,catlg) space=(trk,(10,1)) volser=abc123; proc source nodata noprint indd=inpds outdd=gen; before 'proc download infile=inpds(xxxxxxxx)' 28 noblank; before " outfile='xxxxxxxx.sas';" 24 noblank; before 'run;'; run; %include gen; /* =================================================== */ /* Example 20. Data Transfer Services: Combining */ /* Data from Multiple Remote Sessions (p. 49) */ /* establish link to MVS */ /* NOTE: You must supply a value for MVS-script-file */ options remote=a comamid=ehllapi; filename rlink 'MVS-script-file'; signon a; /* download DB2 data using SAS/ACCESS view */ /* NOTE: You must supply a value for */ /* SAS-library-with-DB2-descriptor */ rsubmit a; libname db 'SAS-library-with-DB2-descriptor' disp=shr; proc download data=db.employee out=db2dat; run; endrsubmit; /* establish link to VMS */ /* NOTE: You must supply a value for /* internet-address and for VMS-script-file */ options remote=internet-address comamid=tcp; filename rlink 'VMS-script-file'; signon internet address; /* download ORACLE data using SAS/ACCESS view */ /* NOTE: You must supply a value for */ /* SAS-library-with-ORACLE-descriptor */ rsubmit internet-address; libname oracle 'SAS-library-with-ORACLE-descriptor'; proc download data=oracle.employee out=oracdat; run; endrsubmit; /* sign off both links */ signoff internet-address; filename rlink 'MVS-script-file '; signoff a; /* join data into SAS view */ proc sql; create view joindat as select * from db2dat, oracdat where oracdat.emp=db2dat.emp; /* create summary table */ proc tabulate data=joindat format=dollar14.2; class workdept sex; var salary; table workdept*(mean sum) all, salary*sex; title1 'Worldwide Inc. Salary Analysis by Departments'; title2 'Data Extracted from Corporate DB2 Database'; run; /* display graphics */ proc gchart data=joindat; vbar workdept/type=sum sumvar=salary subgroup=sex ascending autoref width=6 ctext=cyan; pattern1 v=s c=cyan; pattern2 v=s c=magenta; format salary dollar14.; title1 h=5.5pct f=duplex c=white 'Worldwide Inc. Salary Analysis'; title2 h=4.75pct f=duplex c=white 'Data Extracted from Corporate DB2 Database'; run; quit; /* =================================================== */ /* Example 21. Compute Services and Data */ /* Transfer Services Combined (p. 53) */ /* prepare to sign on */ /* NOTE: You must supply a value for: script-file-name, */ /* communications-access-method, remote-session-id, */ /* local-SAS-data-library */ filename rlink 'script-file-name'; options comamid=communications-access-method remote=remote-session-id ; libname lhost 'local-SAS-data-library'; /* sign on and download data set */ /* NOTE: You must supply a value for */ /* remote-SAS-data-library */ signon remote-session-id ; rsubmit remote-session-id ; libname rhost 'remote-SAS-data-library'; proc sort data=rhost.master out=rhost.sales where gross > 5000; by lname dept; run; proc download data=rhost.sales out=lhost.sales; run; endrsubmit; /* print data set in local session */ proc print data=lhost.sales; run; /* =================================================== */ /* Example 22. Compute Services and Data */ /* Transfer Services Combined (p. 55) */ INIT: submit continue; signon atlanta; rsubmit; libname mres "d:\\counter"; libname backup "d:\\counter\\backup"; rsubmit; proc upload data=hq.reserv out=update status=no; where origin="Atlanta"; run; proc sort data=update; by resnum; run; proc copy in=mres out=backup; select reserv; run; data mres.reserv; update mres.reserv update; by resnum; run; endrsubmit; signoff; endsubmit; /* =================================================== */ /* Example 23. Compute Services and Data */ /* Transfer Services Combined: Macro */ /* Capabilities (p. 56) */ /* NOTE: You must supply a value for */ local-SAS-data-library and remote-SAS-data-library */ libname trans 'local-SAS-data-library'; rsubmit; proc upload data=trans.current out=current; run; %sysrput retcode=&sysinfo; %macro updatem; %if &sysinfo=0 %then %do; libname perm 'remote-SAS-data-library'; data perm.employee; update perm.employee current; by empid; run; %end; %else %put UPLOAD of CURRENT failed. Master file was not updated.; %mend updatem; %updatem endrsubmit; %macro chkcode; %if &retcode=0 %then %do; proc datasets lib=trans; copy out=backup; run; %end; %mend chkcode; %chkcode /* =================================================== */ /* Example 24. RLS and UPLOAD/DOWNLOAD */ /* Combined: Distribution of Reports Over a */ /* Network (p. 58) */ /*----------------------------------*/ /* Name: DISTRPT.PROGRAM */ /* */ /* This program distributes reports */ /* to the franchise offices. */ /* */ /*----------------------------------*/ length rc 8; INIT: submit continue; /* set up distribution macro */ %macro distrib; %let francity=Atlanta NYC LA Dallas Chicago; %let franhost=mvsatl unixnyc unixla vaxdal hqvax; %let j=1; %do %while(%scan(&francity,&j) ne ); %let nextfran=%scan(&francity,&j); %let nextrem=%scan(&franhost,&j); ... %let j=%eval(&j+1); %end; options remote=&nextrem; signon; x "alloc fi(xferrpt) da('sascgg.sugi18.xferrpt') shr"; rsubmit; filename frptlib "d:\\counter\\reports\\prod"; endrsubmit; /* use SAS/CONNECT server */ libname rpt REMOTE "d:\\counter\\reports" server=&nextrem; data _null_; set rpt.preport end=finish; file xferrpt; if _n_ = 1 then put "rsubmit;"; /* transfer desired reports named by */ /* name variable in preport data set */ if (copy = "Y") then do; put "proc upload infile='sascgg.sugi18."name"'"; put "outfile=frptlib("name") status=no;run;"; end; if finish then put "endrsubmit;"; run; /* upload desired reports */ %include xferrpt; signoff; %end; /* do until */ %end; %mend; /* invoke macro to distribute reports */ %distrib; endsubmit; _status_ = 'H'; return; MAIN: return; TERM: return; /* =================================================== */ /* Example 25. Script for EHLLAPI Connections (p. 72) */ /* trace on; */ /* echo on; */ /*--------------------------------------------------------------------- Copyright (C) 1990 by SAS Institute Inc., Cary NC name: cms.scr purpose: SAS/CONNECT SIGNON/SIGNOFF script for connecting to a CMS host using the EHLLAPI or RASYNC access methods from a local OS/2 system or the EHLLAPI access method from a local WINDOWS 3.0 system. notes: 1. The communication parameters may need to be changed for your site. assumes: 1. This script assumes the remote session is already logged on. 2. The command to execute SAS in your remote (CMS) environment is "sas". If this is incorrect for your site, change the contents of the line that contains ... type "sas ... support: SAS Institute staff --------------------------------------------------------------------*/ log "NOTE: Script file 'cms.scr' entered."; if signoff then goto signoff; if fullscreen then goto on32; /*---- RASYNC SIGNON FROM A LOCAL OS/2 SYSTEM -----------------------*/ log 'NOTE: Signing on async device.'; baud 1200; parity none; stopbits 1; databits 8; type cr; waitfor 'dc1', 10 seconds: noinit; type 'set autoread on' cr; waitfor dc1, 20 seconds: timeout; type 'terminal linesize off' cr; waitfor dc1, 20 seconds: timeout; type 'set blip off' cr; waitfor dc1, 20 seconds: timeout; log 'NOTE: Starting remote SAS now.'; /* noterminal suppressses prompts from remote SAS session. */ /* no$syntaxcheck prevents remote side from going into syntax */ /* checking mode when a syntax error is encountered. */ type 'sas (dmr comamid=rasync noterminal no$syntaxcheck)' cr; waitfor 'PACKET': onok, 60 seconds: nosas; /*---- EHLLAPI SIGNON -----------------------------------------------*/ on32: log 'NOTE: Signing on fullscreen device.'; type clear; waitfor 'VM READ', 'RUNNING', 20 seconds: noinit; log 'NOTE: Starting remote SAS now.'; /* noterminal suppressses prompts from remote SAS session. */ /* no$syntaxcheck prevents remote side from going into syntax */ /* checking mode when a syntax error is encountered. */ type 'sas (dmr comamid=pclink noterminal no$syntaxcheck)' enter; goto continue; continue: waitfor 'IN PROGRESS', 60 seconds: nosas; onok: log 'NOTE: SAS/CONNECT conversation established.'; stop; /*---- RASYNC SIGNOFF -----------------------------------------------*/ /*---- EHLLAPI SIGNOFF ----------------------------------------------*/ signoff: log 'NOTE: SAS/CONNECT conversation terminated.'; log 'NOTE: Remote session left logged on.'; stop; /*----- SUBROUTINES -------------------------------------------------*/ /*----- ERROR HANDLING ----------------------------------------------*/ noinit: snapshot; log 'ERROR: Did not get remote prompt. Remote session not active.'; log 'NOTE: You must log on to the remote session before signing on'; log ' using this script file.'; abort; nosas: snapshot; log 'ERROR: Did not get SAS software startup messages.'; abort; timeout: log 'ERROR: Timeout waiting for remote session response.'; abort; /* =================================================== */ /* Example 26. Script for TCP/IP Connections (p. 75) */ /* trace on; */ /* echo on; */ /*-------------------------------------------------------------------*/ /*-- Copyright (C) 1990 by SAS Institute Inc., Cary NC --*/ /*-- --*/ /*-- name: tcpunix.scr --*/ /*-- --*/ /*-- purpose: SAS/CONNECT SIGNON/SIGNOFF script for connecting --*/ /*-- to any UNIX host via the TCP access method --*/ /*-- --*/ /*-- notes: 1. This script may need modifications that account --*/ /*-- for the local flavour of your UNIX environment. --*/ /*-- The logon procedure should mimic the events that --*/ /*-- you go through when "telnet"-ing to the same --*/ /*-- UNIX host. --*/ /*-- --*/ /*-- 2. You must have specified OPTIONS COMAMID=TCP --*/ /*-- in the local SAS session before using the signon --*/ /*-- command. --*/ /*-- --*/ /*-- assumes: 1. The command to execute SAS in your remote (UNIX) --*/ /*-- environment is "sas". If this is incorrect --*/ /*-- for your site, change the contents of the line --*/ /*-- that contains: --*/ /*-- type 'sas ... --*/ /*-- --*/ /*-- support: SAS Institute staff --*/ /*-- --*/ /*-------------------------------------------------------------------*/ log "NOTE: Script file 'tcpunix.scr' entered."; if not tcp then goto notcp; if signoff then goto signoff; /* --------------- TCP SIGNON ------------------------------------*/ waitfor 'login:' , 120 seconds: noinit; /*----------------UNIX LOGON---------------------------------------*/ /*-- for some reason, it needs a LF to turn the line around --*/ /*-- after the login name has been typed. (A CR will not do) --*/ /*-----------------------------------------------------------------*/ input 'Userid?'; waitfor 'Password', 30 seconds : nolog; input nodisplay 'Password?'; type LF; unx_log: waitfor '$' , '>' /*-- another common prompt character --*/ , '%' /*-- another common prompt character --*/ , '}' /*-- another common prompt character --*/ , 'Login incorrect' : nouser , 'Enter terminal type' : unx_term , 30 seconds : timeout ; log 'NOTE: Logged onto UNIX... Starting remote SAS now.'; /* noterminal suppressses prompts from remote SAS session. */ /* no$syntaxcheck prevents remote side from going into syntax */ /* checking mode when a syntax error is encountered. */ type 'sas -dmr -comamid tcp -device grlink -noterminal -no\$syntaxcheck' LF; waitfor 'SESSION ESTABLISHED', 90 seconds : nosas; log 'NOTE: SAS/CONNECT conversation established.'; stop; /*---------------- TCP SIGNOFF --------------------------------------*/ signoff: waitfor '$' , '>' /*-- another common prompt character --*/ , '%' /*-- another common prompt character --*/ , '}' /*-- another common prompt character --*/ , 30 seconds ; type 'logout' LF; log 'NOTE: SAS/CONNECT conversation terminated.'; stop; /*--------------- SUBROUTINES -----------------------------------*/ unx_term: /*---------------------------------------------------------------*/ /*-- some unixen want the terminal-type. --*/ /*-- so tell them we are the most basic of terminals. --*/ /*---------------------------------------------------------------*/ type 'tty' LF; goto unx_log; /*--------------- ERROR ROUTINES --------------------------------*/ timeout: log 'ERROR: Timeout waiting for remote session response.'; abort; nouser: log 'ERROR: Unrecognized userid or password.'; abort; notcp: log 'ERROR: Incorrect communications access method.'; log 'NOTE: You must set "OPTIONS COMAMID=TCP;" before using this'; log ' script file.'; abort; noinit: log 'ERROR: Did not understand remote session banner.'; nolog: log 'ERROR: Did not receive userid or password prompt.'; abort; nosas: log 'ERROR: Did not get SAS software startup messages.'; abort; /* =================================================== */ /* Example 27. Automatic Logon (p. 79) */ /* trace on; */ /* echo on; */ /*-------------------------------------------------------------------*/ /*-- Copyright (C) 1990 by SAS Institute Inc., Cary NC --*/ /*-- --*/ /*-- name: tcpvms.scr --*/ /*-- --*/ /*-- purpose: SAS/CONNECT SIGNON/SIGNOFF script for connecting --*/ /*-- to any VMS host via the TCP access method. --*/ /*-- --*/ /*-- notes: 1. This script may need modifications that account --*/ /*-- for the local flavour of your VMS environment. --*/ /*-- The logon procedure should mimic the events that --*/ /*-- you go through when "telnet"-ing to the same --*/ /*-- VMS host. --*/ /*-- --*/ /*-- 2. You must have specified OPTIONS COMAMID=TCP --*/ /*-- in the local SAS session before using the signon --*/ /*-- command. --*/ /*-- --*/ /*-- assumes: 1. The command to execute SAS in your remote (VMS) --*/ /*-- environment is "sas". If this is incorrect for --*/ /*-- your site, change the contents of the line that --*/ /*-- contains: --*/ /*-- type "sas ... --*/ /*-- --*/ /*-- 2. The remote (VMS) system prompt is a "$". --*/ /*-- --*/ /*-- support: SAS Institute staff --*/ /*-- --*/ /*-------------------------------------------------------------------*/ log "NOTE: Script file 'tcpvms.scr' entered."; if not tcp then goto notcp; if signoff then goto signoff; /*---------------------------VMS LOGON-------------------------------*/ waitfor 'Username:', 120 seconds : noinit; input 'Userid?'; type CR; waitfor 'Password:', 60 seconds : nopass; input nodisplay 'Password?'; type CR; waitfor '$', 'authorization failure' : nouser, 120 seconds : nostrt; strt_sas: log 'NOTE: Logged on to VMS.... Starting remote SAS now.'; /* noterminal suppressses prompts from remote SAS session. */ /* no$syntaxcheck prevents remote side from going into syntax */ /* checking mode when a syntax error is encountered. */ type 'SAS/DMR/COMAMID=TCP/DEVICE=GRLINK/NOTERMINAL/NO$SYNTAXCHECK' CR; waitfor 'SESSION ESTABLISHED', 120 seconds : nosas; log 'NOTE: SAS/CONNECT conversation established'; stop; /*---------------------------VMS LOGOFF-------------------------------*/ signoff: type 'logout' CR; waitfor 'logged out at' , 120 seconds : noterm; log 'NOTE: SAS/CONNECT conversation terminated.'; stop; /*--------------- ERROR ROUTINES --------------------------------*/ notcp: log 'ERROR: Incorrect communications access method.'; log 'NOTE: You must set "OPTIONS COMAMID=TCP;" before using this'; log ' script file.'; abort; nouser: log 'ERROR: Invalid USERNAME/PASSWORD combination.'; abort; noinit: log 'ERROR: Did not understand remote session banner.'; abort; nopass: log 'ERROR: Did not get password prompt.'; abort; nostrt: snapshot; log 'ERROR: Did not get VMS startup messages after logon.'; abort; nosas: snapshot; log 'ERROR: Did not get SAS software startup messages.'; abort; noterm: snapshot; log 'WARNING: Did not get messages confirming logoff.'; abort; /* =================================================== */ /* Example 28. Manual Logon (p. 82) */ /* trace on; */ /* echo on; */ /*--------------------------------------------------------------------- Copyright (C) 1990 by SAS Institute Inc., Cary NC name: tso.scr purpose: SAS/CONNECT SIGNON/SIGNOFF script for connecting to a MVS/TSO host using either the EHLLAPI or RASYNC access method from a local OS/2 system or the EHLLAPI access method from a local WINDOWS 3.0 system notes: 1. The communication parameters may need to be changed for your site. assumes: 1. This script assumes the remote session is already logged on. 2. The command to execute SAS in your remote (MVS/TSO) environment is "sas". If this is incorrect for your site, change the contents of the line that contains ... type "sas ... support: SAS Institute staff --------------------------------------------------------------------*/ log "NOTE: Script file 'tso.scr' entered."; if signoff then goto signoff; if fullscreen then goto on32; /*---- RASYNC SIGNON FROM A LOCAL OS/2 SYSTEM------------------------*/ log 'NOTE: Signing on async device.'; baud 1200; parity none; stopbits 1; databits 8; type cr; waitfor 'READY', 10 seconds: noinit; waitfor 1 second; log 'NOTE: Starting remote SAS now.'; /* noterminal suppressses prompts from remote SAS session. */ /* no$syntaxcheck prevents remote side from going into syntax */ /* checking mode when a syntax error is encountered. */ type "sas options('dmr,comamid=rasync,noterminal,no$syntaxcheck')" cr; waitfor 'PACKET': onok, 60 seconds: nosas; /*---- EHLLAPI SIGNON -----------------------------------------------*/ on32: log 'NOTE: Signing on fullscreen device.'; waitfor 'READY', 0 seconds: noinit; log 'NOTE: Starting remote SAS now.'; /* noterminal suppressses prompts from remote SAS session. */ /* no$syntaxcheck prevents remote side from going into syntax */ /* checking mode when a syntax error is encountered. */ type "sas options('dmr,comamid=pclink,noterminal,no$syntaxcheck')" enter; goto continue; continue: waitfor 'IN PROGRESS', 20 seconds: waitsas; onok: log 'NOTE: SAS/CONNECT conversation established.'; stop; /*---- RASYNC SIGNOFF -----------------------------------------------*/ /*---- EHLLAPI SIGNOFF ----------------------------------------------*/ signoff: log 'NOTE: SAS/CONNECT conversation terminated.'; log 'NOTE: Remote session left logged on.'; stop; /*----- SUBROUTINES -------------------------------------------------*/ waitsas: log 'NOTE: Waiting for startup screen...'; type EREOF enter; goto continue; /*----- ERROR HANDLING ----------------------------------------------*/ noinit: snapshot; log 'ERROR: Did not get remote prompt. Remote session not active.'; log 'NOTE: You must log on to the remote session before signing on'; log ' using this script file.'; abort; nosas: snapshot; log 'ERROR: Did not get SAS software startup messages.'; abort; /* =================================================== */ /* Example 29. Locating and Storing Sample */ /* Script Files with SCL Functions (p. 85) */ INIT; return; MAIN: /* Get internally-assigned fileref */ fileref=optgetc('sasfrscr'); /* Open the directory (aggregate storage location) */ dirid=dopen(fileref); /* Get the number of files */ numfiles=dnum(dirid); /* Define a custom selection list the length of the */ /* number of files and allowing users to make one choice. */ call setrow(numfiles,1); return; TERM: /* Close the directory */ rc=dclose(dirid); return; GETROW: /* Display the list of file names */ filename=dread(dirid,_currow_); return; PUTROW: /* Get directory path name. */ fullname=pathname(fileref); /* Concatename file name user selects with directory pathname. */ name=fullname ||'/'|| filename; /* other SCL statements to use complete file name stored in name */ return; /* =================================================== */ /* Example 30. Sample Script Connecting to */ /* VSE with a Protocol Converter (p. 153) */ /* trace on; */ /* echo on; */ /*---------------------------------------------------------------------------- Copyright (C) 1992 by SAS Institute Inc., Cary NC name: vsecics.scr purpose: SAS/CONNECT SIGNON/SIGNOFF script for connecting to a VSE host via CICS using either the EHLLAPI or RASYNC access methods from a local OS/2 system or the EHLLAPI access method from a local WINDOWS 3.0 system. notes: 1. The communication parameters may need to be changed for your site. assumes: 1. This script assumes the SAS/VSE host supervisor is already up and running and CICS is ready to accept the SAS transaction. 2. The command to invoke the SAS CICS transaction is "sasc". If this is incorrect for your site, change the contents of the lines that contain... type "sasc ... support: SAS Institute Staff ----------------------------------------------------------------------------*/ log "NOTE: Script file 'vsecics.scr' entered."; if signoff then goto signoff; /*---------------------------------------------------------------------------- The emulation session should already be connected to CICS. CICS should be ready to accept the SAS transaction. ----------------------------------------------------------------------------*/ if fullscreen then goto on32; /*--- RASYNC SIGNON FROM A LOCAL OS/2 SYSTEM -------------------------------*/ log 'NOTE: Signing on to VSE via an IBM 7171 protocol converter'; baud 9600; parity none; databits 8; stopbits 1; handshaking none; maxi 220; maxo 220; .newpage /*---------------------------------------------------------------------------- Invoke the SAS CICS transaction to start a remote VSE SAS session. Note: The 7171 protocol converter does not support extended data stream (non-queriable device). The SAS CICS transaction, 'sasc', may be different at your site. ----------------------------------------------------------------------------*/ log "NOTE: Starting remote SAS now."; /* noterminal suppressses prompts from remote SAS session. */ /* no$syntaxcheck prevents remote side from going into syntax */ /* checking mode when a syntax error is encountered. */ type "sasc 'dmr comamid=rsas7171 noterminal no$syntaxcheck'" ENTER; /*------------------- logon to SAS Multiuser system ------------------------*/ waitfor 'Enter your SAS userid:', 5 seconds: nouserid; input 'Enter SAS userid:'; type ENTER; waitfor 'Enter password', 5 seconds: nopasswd; input nodisplay 'Enter password:'; type ENTER; waitfor 'PACKET': onok, 120 seconds: nosas; /*--------------------------- signoff --------------------------------------*/ signoff: log 'NOTE: SAS/CONNECT conversation terminated.'; stop; /*---------------------- ERROR HANDLING ------------------------------------*/ nouserid: nopasswd: log 'ERROR: Did not get userid or password prompt.'; log ' Snapshot of emulation session follows:'; snapshot; abort; nosas: log 'ERROR: Did not get SAS Multiuser startup messages.'; log ' Snapshot of emulation session follows:'; snapshot; abort; /* =================================================== */ /* Example 31. A Sample Keyboard Translation */ /* Table, CUTMODE.XLT (p. 306) */ 0123456789RLINKXTABLE Copyright 1986, SAS Institute, Cary, N.C. USA 00 0000 NUL 01 0000 SOH RLINK optional "CUT" mode translate table for 02 0000 STX the standard US 3278/79 typewriter keyboard. 03 0000 ETX 04 0000 EOT 05 0000 ENQ - can be used by Irma, Forte and IBM 78/79RLINK. 06 0000 ACK 07 0000 BEL First line must be left in original form. 08 0031 BS = left arrow This translate table can be up to 257 lines long 09 0036 HT = tab and need not have all 256 hex entries present. 0A 0008 LF 0B 0000 VT Table format is as follows: 0C 0000 FF 0D 1018 CR = Enter columns 0-1 hex index of char to be translated 0E 0000 SO column 3 0 = buffered key 1 = attention key 0F 0000 SI columns 4 0 = unshifted 1 = ALT 2 = SHIFTED 10 0000 DLE columns 5-6 hex value of 3270 scan code 11 0000 DC1 columns 8... show the typical PC DOS display code 12 0000 DC2 followed by comments 13 0000 DC3 14 0000 DC4 If a hex code shows -unused- it is assigned 15 0000 NAK a 3270 scan code of 0000 or the NULL character. 16 0000 SYN 17 0000 ETB 18 0000 CAN 19 0000 EM NOTE 1A 0000 SUB ---- 1B 0000 ESC 1C 0000 FS As with any 3278/79 Emulation Program, there are 1D 0000 GS certain translation problems between ASCIIand 1E 0000 RS EBCDIC. 1F 0000 US 20 0010 space There are 3 characters in ASCII that are not part 21 021b ! exclamation of the official EBCDIC character set and translate 22 0212 " double quote as follows: 23 0223 # number sign 24 0224 $ dollar sign ASCII ^ (hat) ==> EBCDIC (not sign) 25 0225 % percent ASCII [ (left bracket) ==> EBCDIC (cent sign) 26 0227 & ampersand ASCII ] (right bracket) ==> EBCDIC (solid bar) 27 0012 ' single quote 28 0229 ( left paren You may also enter PC ascii codes for the cent 29 0220 ) right paren sign (alt-155) and the not sign (alt-170) to get 2A 0228 * asterisk the EBCDIC equivalent. 2B 0211 + plus sign 2C 0033 , comma The 3270 Standard TW Keyboard does not contain the 2D 0030 - dash right or left square brackets and so they 2E 0032 . period cannot be entered from RLINK. 2F 0014 / slash 30 0020 0 . 31 0021 1 . 32 0022 2 . 33 0023 3 . 34 0024 4 . 35 0025 5 . numerics 36 0026 6 . 37 0027 7 . 38 0028 8 . 39 0029 9 . 3A 027e : colon 3B 007e ; semi-colon 3C 0009 < less than 3D 0011 = equals 3E 0209 > greater than 3F 0214 ? question mark 40 0222 @ at sign 41 0260 A . 42 0261 B . 43 0262 C . 44 0263 D . 45 0264 E . 46 0265 F . 47 0266 G . 48 0267 H . 49 0268 I . 4A 0269 J . 4B 026a K . 4C 026b L . upper case letters 4D 026c M . 4E 026d N . 4F 026e O . 50 026f P . 51 0270 Q . 52 0271 R . 53 0272 S . 54 0273 T . 55 0274 U . 56 0275 V . 57 0276 W . 58 0277 X . 59 0278 Y . 5A 0279 Z . 5B 001b [ left square bracket * inputs EBCDIC cent sign 5C 0015 \ reverse slash 5D 0221 ] right square bracket * inputs EBCDIC solid bar \| 5E 0226 ^ hat * inputs EBCDIC logical not sign 5F 0230 _ underscore 60 003d ` reverse single quote 61 0060 a . 62 0061 b . 63 0062 c . 64 0063 d . 65 0064 e . 66 0065 f . 67 0066 g . 68 0067 h . 69 0068 i . 6A 0069 j . 6B 006a k . 6C 006b l . lower case letters 6D 006c m . 6E 006d n . 6F 006e o . 70 006f p . 71 0070 q . 72 0071 r . 73 0072 s . 74 0073 t . 75 0074 u . 76 0075 v . 77 0076 w . 78 0077 x . 79 0078 y . 7A 0079 z . 7B 000f { left brace 7C 0215 | broken bar \* There should be a broken vertical bar here */ 7D 020f } right brace 7E 023d ~ tilde 7F 0031 rubout, delete = left arrow 80 0000 p0033; . /* fonts for following characters not available to PUBLISH yet */ 81 0000 p331; . 82 0000 p333; . 83 0000 p331; . 84 0000 p331; . 85 0000 p333; . 86 0000 p331; . 87 0000 p331; . 88 0000 p333; . 89 0000 p331; . 8A 0000 p333; . 8B 0000 p331; . 8C 0000 p331; . 8D 0000 i . foreign PC DOS symbols are unused in US translate table 8E 0000 p331; . 8F 0000 A . 90 0000 p333; . 91 0000 p331; . 92 0000 p331; . 93 0000 p331; . 94 0000 p331; . 95 0000 o . 96 0000 p331; . 97 0000 p333; . 98 0000 y . 99 0000 p331; . 9A 0000 p331; . 9B 0000 cent sign * not a normal ascii character 9C 0000 p331; . 9D 0000 . 9E 0000 Pt . 9F 0000 p331; . A0 0000 p331; . A1 0000 i . A2 0000 o . foreign PC DOS symbols are unused in US translate table A3 0000 u . A4 0000 n . A5 0000 N . A6 0000 underscored a . A7 0000 underscored o . A8 0000 p331; . A9 0000 BREAK (used to signal an asynchronous "break") AA 0226 logical not sign * not a normal ascii character AB 0000 -unused- AC 0000 -unused- AD 0000 -unused- AE 0000 -unused- AF 0000 -unused- B0 1121 PF1 B1 1122 PF2 B2 1123 PF3 B3 1124 PF4 B4 1125 PF5 B5 1126 PF6 B6 1127 PF7 B7 1128 PF8 B8 1129 PF9 B9 1120 PF10 BA 1130 PF11 BB 1111 PF12 BC 1040 PF13 BD 1041 PF14 BE 1042 PF15 BF 1043 PF16 C0 1044 PF17 C1 1045 PF18 C2 1046 PF19 C3 1047 PF20 C4 1048 PF21 C5 1049 PF22 C6 104a PF23 C7 104b PF24 C8 115f PA1 C9 115e PA2 CA 110c PA3 CB 1151 clear CC 1018 enter CD 1050 attn CE 1150 sys req CF 1051 cursor select D0 0034 reset D1 000e up arrow D2 0013 dn arrow D3 001a rt arrow D4 0016 lf arrow D5 0036 tab D6 0035 back tab D7 0008 new line D8 0135 home D9 000c insert DA 000d delete DB 0053 erase input DC 0055 erase eof DD 005e field mark DE 0056 print DF 005f dup E0 0000 alpha . E1 0000 Beta . E2 0000 Gamma . E3 0000 pi . E4 0000 Sigma . E5 0000 sigma . E6 0000 mu . E7 0000 tau . reserved for Greek alphabet or other special symbols E8 0000 Phi . E9 0000 eta . EA 0000 Omega . EB 0000 delta . EC 0000 omega . ED 0000 phi . EE 0000 epsilon . EF 0000 eta . F0 0052 change format . F1 010e cursor position . F2 0152 doc on/off . F3 010d word delete . F4 0156 ident/wrap . special purpose 3270 keys F5 0116 fast cursor left . F6 011a fast cursor right . F7 0134 device cancel . F8 0154 alt cursor . F9 016f test . FA 0000 -unused- FB 0000 -unused- FC 0000 -unused- FD 0000 -unused- table need not have all 256 entries present FE 0000 -unused- FF 0000 -unused- *** end of translate table *** /* =================================================== */ /* Example 32. Micro-to-Host Link Automated */ /* Remote Processing (p. 312) */ /* BACKUP.SAS */ /* NOTE: You must supply a value for */ /* remote-SAS-data-library */ x 'dir \ sales\*.ssd > dir.dat'; data _null_; infile 'dir.dat' length=len end=finish; length card $ 80.; input card $varying80. len; file '\ sales\ upload.sas'; if _n_=1 then do; put "libname lhost '\ sales';"; put "dm 'signon';"; put "dm 'rsubmit';"; put "libname rhost 'remote-SAS-data-library';"; end; if substr(card,10,3)="SSD" then do; record=substr(card,1,8); put "proc upload data=lhost." record " out=rhost." record ";"; put "run;"; end; if finish then do; put "endrsubmit;"; put "dm 'signoff';"; put "run;"; end; run; dm "inc '\ sales\ upload.sas'"; dm "submit"; run; /* *** END OF FILE *********************************************** */