Learning SAS? Welcome to the exclusive online community for all SAS learners.

Syntax for cport, cimport, cntlout, cntlin

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 8
Accepted Solution

Syntax for cport, cimport, cntlout, cntlin

I'm having trouble applying a formats.sas7bcat file to a new library.  I receive the error that the catalog was created for a different operating system.  So I'm trying to port the formats file between folders on my current system (SAS Studio University Edition = UNIX) to convert it for the current environment.

I'm having trouble understanding the SAS documentation:

What is the format of 'transport-file' below?  Is it a file name appended to a path?

libname source 'SAS-data-library';

filename tranfile 'transport-filehost-option(s)-for-file-characteristics;

proc cport library=source file=tranfile memtype=catalog; run;

Similarly, regarding the documentation for proc format cntlout and proc format cntlin.

Does anyone know what the text between the quotes should be, specifically?  The first looks like a path, but the second looks like... maybe a path with a file name and extension at the end?

'location-of-existing-formats-catalog';

'data-set-name-from-sending-site'

Thank you!


Accepted Solutions
Solution
‎07-10-2015 08:32 PM
Super User
Super User
Posts: 7,081

Re: Syntax for cport, cimport, cntlout, cntlin

The key issue is that you must have exported the catalog first on the OLD system that can read it.  If you do not have access to a system that can read the catalog then you cannot import it.

You can use PROC CPORT to export the catalog and PROC CIMPORT to read it back in.

Syntax for PROC CPORT is

PROC CPORT CAT=libref.memname FILE=filename; run;

Syntax for PROC IMPORT is

PROC CIMPORT LIB=libref INFILE=filename; run;

So if you have a catalog named "myformats.sas7bcat" in a folder named "myfolder" on your OLD system that you want to write into a CPORT formatted file named "myformats.cport" you would run these lines of code.

LIBNAME myfmts "myfolder" ;

PROC CPORT CAT=myfmts.myformats FILE="myformats.cport" ; run;

Then on you NEW system if you had copied this to a file named "my_old_formats.cport" and wanted to import this into a folder named "my_new_folder" you would run these commands:

LIBNAME myfmts "my_new_folder";

PROC CIMPORT LIB=myfmts INFILE="my_old_formats.cport"; run;

You should then see the format catalog MYFMTS.MYFORMATS on your new system.

You could also use FILENAME statements to make filerefs to point to the output and input files. Then in the FILE= or INFILE= option you would just use the fileref defined by your FILENAME statement instead of the quoted physical filename.

View solution in original post


All Replies
Super User
Posts: 11,343

Re: Syntax for cport, cimport, cntlout, cntlin

Transport_file is any (best fully qualified) path and file name such as C:\myfolder\myotherfolder\mytransportfile.xport

Cntlin and cntlout are just SAS data set names.

In the "current system:

proc format library=yourlib cntlout=work.libcntlout; run;

and data sent name would do to create the cntlout. Then transport it to the UNIX system.

After you have imported the cntlout then use

proc format library= libname cntlin=work.libnctlout; run; to use that data set to make the formats in the library you specify.

Occasional Contributor
Posts: 8

Re: Syntax for cport, cimport, cntlout, cntlin

Thanks, ballardw!

Solution
‎07-10-2015 08:32 PM
Super User
Super User
Posts: 7,081

Re: Syntax for cport, cimport, cntlout, cntlin

The key issue is that you must have exported the catalog first on the OLD system that can read it.  If you do not have access to a system that can read the catalog then you cannot import it.

You can use PROC CPORT to export the catalog and PROC CIMPORT to read it back in.

Syntax for PROC CPORT is

PROC CPORT CAT=libref.memname FILE=filename; run;

Syntax for PROC IMPORT is

PROC CIMPORT LIB=libref INFILE=filename; run;

So if you have a catalog named "myformats.sas7bcat" in a folder named "myfolder" on your OLD system that you want to write into a CPORT formatted file named "myformats.cport" you would run these lines of code.

LIBNAME myfmts "myfolder" ;

PROC CPORT CAT=myfmts.myformats FILE="myformats.cport" ; run;

Then on you NEW system if you had copied this to a file named "my_old_formats.cport" and wanted to import this into a folder named "my_new_folder" you would run these commands:

LIBNAME myfmts "my_new_folder";

PROC CIMPORT LIB=myfmts INFILE="my_old_formats.cport"; run;

You should then see the format catalog MYFMTS.MYFORMATS on your new system.

You could also use FILENAME statements to make filerefs to point to the output and input files. Then in the FILE= or INFILE= option you would just use the fileref defined by your FILENAME statement instead of the quoted physical filename.

Occasional Contributor
Posts: 8

Re: Syntax for cport, cimport, cntlout, cntlin

Thanks, Tom!  That's the key -- i do not have access to the old machine or operating environment.  So I will have to figure out something else. I didn't get a chance to run the code, but the way you broke down the process was extremely helpful, and I would have understood much better what I was doing!

Cheers!Smiley Happy

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 473 views
  • 3 likes
  • 3 in conversation