Mailer: Elm [revision: 66.25]
Newsgroups: bit.listserv.sas-l
Date:         Fri, 18 Dec 1992 16:47:36 MET
Reply-To:     Juan Gregorio <juangre@FENIX.UB.ES>
From:         Juan Gregorio <juangre@FENIX.UB.ES>
Subject:      SAS to SPSS in CMS
Comments: To: SAS List <sas-l@awiimc12.imc.univie.ac.at>

Hi net,

        After the discussion in this list about transforming SAS data sets to SP
SS, I
 have a program in REXX to make this transformation. I have used the mails
 received in this list, specially one from Melvin Klassen.

        I hope this will be useful.

        After this signature is the program :
--
+------------------------------------------+----------------------------------+
! Juan Gregorio de las Heras               ! E-Mail:   juangre@fenix.ub.es    !
! Informatica de Recerca i Docencia        !                                  !
! Universitat de Barcelona                 +----------------------------------+
! Avda. Diagonal 696                       ! voice:    34-3-280-00-18         !
! 08034 Barcelona -- Spain                 ! fax:      34-3-280-41-60         !
+------------------------------------------+----------------------------------+


#---- cut here ---------------------------------------------------------------

/*
   JUANGRE de las Heras <juangre@fenix.ub.es>

   Transform a V6 SAS data set into a system SPSS file in CMS

   This programa uses the program ALTSASV6 from Melvin Klassen
   <KLASSEN@UVVM> to transform our V5 file to V5.18
*/
address command
PARSE UPPER ARG FNV6 FTV6 FMV6
call initvars
call header
call V6toV5
call altsasV6
call SAStoSPSS
call theend
exit 0

initvars :
parse source sys .
If Sys = 'CMS' Then
  If CMSFlag('CMSTYPE') Then RT? = 'RT'; Else RT? = 'HT'
if FMV6 = ' ' then FMV6 = '*'
if exist(FNV6 FTV6 FMV6) = 0 then
  call sayerror 1, 'The file' FNV6 FTV6 FMV6 'does not exist'
FNV5 = 'SAS2SPSS'
FTV5 = 'TMP'
FMV5 = 'A'
FNSX = FNV6
FTSX = 'SYS'
FMSX = FMV6
FTMP1 = 'TMPV6V5 SAS A'
FTMP2 = 'TMPSPSS SPSS A'
if FNV6 = ' ' | FTV6 = ' ' then call usage
return

usage :
say
say 'SAS2SPSS'
say '(c) Juangre de las Heras <juangre@fenix.ub.es>'
say
say 'Transform a V6 SAS data set into a system SPSS file in CMS'
say
say 'Syntax :'
say '         SAS2SPSS <fn> <ft> <fm>'
say
say 'Creates the following files:'
say
say '         'FNV5 FTV5 FMV5 '(SAS data set V5)'
say '         <fn> SYS <fm> (SPSS System file)'
say
exit 1
return

header :
say
say 'SAS2SPSS'
say '--------'
say
say 'SAS Library File:' FNV6 FTV6 FMV6
say 'SPSS System File:' FNSX FTSX FMSX
return

Exist:
  Parse Upper Arg AFile
  'SET CMSTYPE HT'
  'STATE' AFile
  SRC = RC
  'SET CMSTYPE' RT?
return src = 0

fwrite :
Parse Arg file, msg
'EXECIO 1 DISKW' file '( VAR MSG'
if rc <> 0 then
  call sayerror rc,'Writing file' file
return

V6toV5 :
say
say 'Converting V6 to V5 ...'
say 'SAS V5 File:' FNV5 FTV5 FMV5
call fwrite FTMP1, 'libname' FTV5 'V5seq '''FMV5''';'
call fwrite FTMP1, 'data' FTV5'.'FNV5';'
call fwrite FTMP1, 'set' FTV6'.'FNV6';'
call fwrite FTMP1, 'run;'
'FINIS' FTMP1
'EXEC SAS' FTMP1
oldrc = rc
'ERASE' FTMP1
if oldrc <> 0 then
   call sayerror oldrc, 'Executing SAS' FTMP1, 'TMPV6V5 SASLOG'
return

altsasV6 :
say
say 'Modifying SAS V5 File ...'
'EXECIO 1 DISKR' FNV5 FTV5 FMV5 '1 ( VAR RECORD1'
if rc <> 0 then call sayerror rc, 'Reading SAS v5 data set' FNV5 FTV5 FMV5
RECORD1 = SUBSTR(RECORD1,1,42) || '85.18' || SUBSTR(RECORD1,48)
'EXECIO 1 DISKW' FNV5 FTV5 FMV5 '1 ( VAR RECORD1 FINIS'
if rc <> 0 then call sayerror rc, 'Writing in SAS v5 data set' FNV5 FTV5 FMV5
return

SAStoSPSS :
say
say 'Converting to SPSS ...'
call fwrite FTMP2, 'get sas data='FTV5'.'FNV5'.'
call fwrite FTMP2, 'save /outfile '''FNSX FTSX FMSX'''.'
'FINIS' FTMP2
'EXEC SPSSX' FTMP2
oldrc = rc
'ERASE' FTMP2
if oldrc <> 0 then
  call sayerror oldrc, 'Executing SPSSX' FTMP2, 'TMPSPSS LISTING'
return

theEND :
say
say 'Done.'
return

sayerror :
parse arg code, msg, file
say 'Error  SAS2SPSS :' msg
if file <> ' ' then
   say 'Look at' file 'for more information'
exit code
return
Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU