BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Nipun22
Obsidian | Level 7
CODE-
libname xptfile xport '/home/u60697506/sasuser.v94/Permanants Libs/XPT/new.xpt';

data cars;
set sashelp.cars;
run;

data xptfile.new;
set cars;
run;

LOG-
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         libname xptfile xport '/home/u60697506/sasuser.v94/Permanants Libs/XPT/new.xpt';
 NOTE: Libref XPTFILE was successfully assigned as follows: 
       Engine:        XPORT 
       Physical Name: /home/u60697506/sasuser.v94/Permanants Libs/XPT/new.xpt
 70         
 71         data cars;
 72         set sashelp.cars;
 73         run;
 
 NOTE: There were 428 observations read from the data set SASHELP.CARS.
 NOTE: The data set WORK.CARS has 428 observations and 15 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              837.40k
       OS Memory           20388.00k
       Timestamp           09/11/2024 04:57:42 PM
       Step Count                        38  Switch Count  2
       Page Faults                       0
       Page Reclaims                     130
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           264
       
 
 74         
 75         data xptfile.new;
 76         set cars;
 77         run;
 
 ERROR: The variable name DriveTrain is illegal for the version 6 file XPTFILE.NEW.DATA.
 NOTE: The SAS System stopped processing this step because of errors.
 WARNING: The data set XPTFILE.NEW was only partially opened and will not be saved.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       user cpu time       0.00 seconds
       system cpu time     0.00 seconds
       memory              735.75k
       OS Memory           20388.00k
       Timestamp           09/11/2024 04:57:42 PM
       Step Count                        39  Switch Count  0
       Page Faults                       0
       Page Reclaims                     59
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           8
       
 
 78         
 79         
 80         
 81         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 91         
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Not sure why the ERROR message mentions V6.  The XPORT format has not changed since V5.  Names are limited to 8 bytes and character variables to a maximum length of 200 bytes and labels are limited to 40 bytes, etc.

 

But SAS did introduce two new autocall macros that can be used to create XPORT files using new SAS V9 format.  The macros are named %LOC2XPT() and %XPT2LOC().

filename xptfile '/home/u60697506/sasuser.v94/Permanants Libs/XPT/cars.xpt';
%loc2xpt(libref=sashelp,memlist=cars,filespec=xptfile,format=v9)

View solution in original post

6 REPLIES 6
ballardw
Super User

The xport engine, which goes back over 30 years, is a bit limited. By default variables are restricted to the 8 character names of SAS V6.

 

Use Proc CPORT /CIMPORT to create transport files with long variable and table names.

Tom
Super User Tom
Super User

Not sure why the ERROR message mentions V6.  The XPORT format has not changed since V5.  Names are limited to 8 bytes and character variables to a maximum length of 200 bytes and labels are limited to 40 bytes, etc.

 

But SAS did introduce two new autocall macros that can be used to create XPORT files using new SAS V9 format.  The macros are named %LOC2XPT() and %XPT2LOC().

filename xptfile '/home/u60697506/sasuser.v94/Permanants Libs/XPT/cars.xpt';
%loc2xpt(libref=sashelp,memlist=cars,filespec=xptfile,format=v9)
Nipun22
Obsidian | Level 7
So, by this we can create XPTs which are version 9 compatible?
Tom
Super User Tom
Super User

@Nipun22 wrote:
So, by this we can create XPTs which are version 9 compatible?

You can create XPORT files that can handle the new features of SAS version 7/8/9 datasets.  https://support.sas.com/kb/46/944.html

 

Note the extension (XPT) that you use to NAME the file has nothing to do with the content of the file.  Unlike CSV or XLSX the extension XPT is not universally understood to indicate a single type of file. You could have a SAS version 5 XPORT format,  or a CPORT format file or something completely different.  If you get sent a file and are unsure what type of file it is you could try using this macro to check.  https://github.com/sasutils/macros/blob/master/xpttype.sas

 

Nipun22
Obsidian | Level 7
Well I guess to keep things simple and easy this works for now but surely will explore other options you have stated in the github link in the future. Thanks again!!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 616 views
  • 2 likes
  • 4 in conversation