DATA Step, Macro, Functions and more

SAS Programs Migration

Posts: 26

SAS Programs Migration



I need to migrate SAS programs of 9.1 from mainframes to Linux (SAS version 9.4). Is there any easy way to migrate all the programs in one go instead of FTPying one by one from Mianframes to Local and then from Local to Linux?


Can PROC CPORT and CIMPORT acheive this?




Regular Contributor
Posts: 226

Re: SAS Programs Migration

Posted in reply to vijayanand

You find the documentation of proc cport there:


Afaik no tool exists to convert programs.

Super User
Super User
Posts: 9,799

Re: SAS Programs Migration

Posted in reply to vijayanand

What do you mean by migration in this sense?  If it is just moving the files from one system to another then compress (7-zip or some similar) all the files up, then FTP that one zip across and unpack.  If you mean there are changes to the code, or there are binary files within then you will need a migration plan.  Datasets could be converted to XPT, same with catalogs - however bear in mind that if you are moving from a 32bit system onto a 64bit system catalogs will not work - there is no migration path for those - you will need to re-compile - take this as one very good reason to never use proprietary compiled formats! 

Super User
Posts: 10,530

Re: SAS Programs Migration

Posted in reply to vijayanand

Program files are text files. This means that you need a tool that converts mainframe text (which uses EBCDIC) to ASCI text (taking care of the codepages used). The simplest tool for that is FTP, as it dows such converision on the fly when asci or text mode is used during the transfer.


You can do a bulk transfer in FTP, depending on how your SAS codes are stored on the mainframe.


If your MF people followed typical MF convention, your SAS codes are stored in a mainframe partitioned dataset named something like PROD.SOURCE.SAS.

SAS code X1234567 would then be adressed in the mainframe catalog as PROD.SOURCE.SAS(X1234567).


When you FTP to the MF, you can change directory (which actually moves you through the levels of the catalog) to PROD.SOURCE.SAS, then do "prompt" (which disables a yes/no prompt for each individual entry), and then use "mget *" to transfer all memebers of PROD.SOURCE.SAS in one step. Do this FTP directly from the UNIX server.

You will then have to take care of adding the proper .sas extension (and probably converting the filenames to lowercase) on the UNIX side.


This all only transfers the codes as such. Adapting the codes to your new environment will require human intervention.

Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Valued Guide
Posts: 505

Re: SAS Programs Migration

Posted in reply to KurtBremser

If you want more control:

You have some good advice, but beware I have gad issues with some of these not converting to ascii. "|" and  "^". You can do the entire process interactively in TSO using SAS. I always thy to use '!!' instead pf '|' and 'NOT' instead of '^'.

This macro will put all the member names of a PDS into a SAS datastep.

%macro pdsmemb(ddname,file=work.members);

  %* find the members of a pds
     by Paul Shipley, Melbourne, Australia
  %* ;

  data &file.;
    keep dsn member;
    infile &ddname recfm=u blksize=256 lrecl=256
                 jfcb=jfcb eov=eov eof=eof;
    do while (1);   /* do forever, eof will exit */
      eov = 0; col = 3; lastmem = 0;
      input count pib2. @;
      do while(eov = 0);
        if lastmem = 0 then do;
          input @col member $8. +3 ind pib1. @;
          if member =< '99999999' then do;
            col = col + 12 + 2*mod(ind,32);
            if col > count then do; /* if end of input, fetch next rec*/
              input; input count pib2. @; col = 3;
          else do; /* if member hi-values, set flag */
            lastmem = 1;
        else do; /* if lastmem flag set skip until eov */
          input; input @;
      end; /* end while (eov=0) */
    end; /* end while (1) */

     stop; /* end of file, stop processing */

%mend pdsmemb;

You can then write a macro to read each member, convert to ascii and fix the 

something like

%macro onetxt(member);
      infile ddname(&member);
      * fix '|' to '!!' and '^' +;
      file ddname mod;
      put _infile_;
%mend onetxt;

You can also use 

Ask a Question
Discussion stats
  • 4 replies
  • 5 in conversation