Hi, all:
I'm using %xpt2loc auto macro statement to convert Xport file into SAS data set. The Xport file was generated by V8 machine, and I'm using SAS 9.4 version.
libname source 'c:\My documents\My SAS Files\IIT';
%xpt2loc(libref=source, memlist=memlist,
filespec='c:\My documents\My SAS Files\IIT'\Data_CID_Keymind_harddrive_02.xpt' );
It gave me an error message,
ERROR: Physical file does not exist.
However, I did exported Xport file, I checked it showes 600KB size with document type of SAS Xport Transport file.
Why? Please help, thanks.
You have an extra quotation mark in your code. You can see it with the colour change in the file spec parameter.
There are two kind of Xport file, One is generated by PROC COPY, another is PROC CPORT. Make sure which one generate that XPT file .
Hi Team
I don't think you need a macro to export/import SAS datasets using the V5 format or the CPORT format. see below for examples.
Note you can use proc fslist with recfm=f lrecl=80 to examine the header records or use the data step list option to detemine which format was used. Card image, 80 byte boundaries, are used for both formats.
I don't think you need a macro to export/import SAS datasets. Below are sample header records for V5 transport and CPORT files. You can use this to determine which type you have. data _null_; infile "d:/xpt/class.xpt" lrecl=80 recfm=f; input; list; if _n_=10 then stop; ;run;quit; Here is what a header looks like for V5 transport RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 1 HEADER RECORD*******LIBRARY HEADER RECORD!!!!!!!000000000000000000000000000000 2 SAS SAS SASLIB 9.4 X64_7PRO 17JUN16:18:01:06 RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 3 17JUN16:18:01:06 4 HEADER RECORD*******MEMBER HEADER RECORD!!!!!!!000000000000000001600000000140 5 HEADER RECORD*******DSCRPTR HEADER RECORD!!!!!!!000000000000000000000000000000 6 SAS CLASS SASDATA 9.4 X64_7PRO 17JUN16:18:01:06 7 17JUN16:18:01:06 8 HEADER RECORD*******NAMESTR HEADER RECORD!!!!!!!000000000500000000000000000000 data _null_; infile "d:/cpt/class.cpt" lrecl=80 recfm=f; input; list; if _n_=10 then stop; ;run;quit; Here is what a header looks like for CPORT. Incompressed it has 80 byte boundaries. RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 1 **COMPRESSED** **COMPRESSED** **COMPRESSED** **COMPRESSED** **COMPRESSED******** 2 CHAR LIB CONTROL X64_7PRO¼. SAS9.4¼ƒI¼¥D901SASHELP CLASS¼™VC5¼‚RC19¼ˆRL40¼ˆ1¼‡S 0 0 ZONE 44424445544253353554B02545323B84BA43335454445244455B9543B85433B85433B83B85232232 NUMR C9203FE42FC0864F702FC603139E4C39C5490131385C003C133C9635C22319C82C40C81C73000000 3 12 NO¼„0¼‰1¼•ansi¼Š¼Î¼ÎStudent Data¼ÂSPAN CONTROL -7¼‚40¼…1¼†40¼ŠL¼ˆ40¼Ž¼&¼¦SPA Here is code for V5 transport and CPORT In V5 variable names cannot be longer than 8 chars and char vars can only hold up to 200 chars. Floats follow the IBM binary format not IEEE. * V5 export; libname xpt xport "d:/xpt/class.xpt"; data xpt.class; set sashelp.class; ;run;quit; * V5 import; data class_import; set xpt.class; ;run;quit; *CPORT; * V9.4M2 CPORT; options compress=no; proc cport data=sashelp.class file="d:/cpt/class.cpt" ; ;run;quit;
CIMPORT proc cimport data=classcpt file="d:/cpt/class.cpt"; ;run;quit; 698 libname xpt xport "d:/xpt/xlass.xpt"; NOTE: Libref XPT was successfully assigned as follows: Engine: XPORT Physical Name: d:\xpt\xlass.xpt 699 data xpt.class; 700 set sashelp.class; 701 ;run; NOTE: There were 19 observations read from the data set SASHELP.CLASS. NOTE: The data set XPT.CLASS has 19 observations and 5 variables. NOTE: DATA statement used (Total process time): real time 0.11 seconds user cpu time 0.01 seconds system cpu time 0.00 seconds memory 457.28k OS Memory 18936.00k Timestamp 06/17/2016 06:01:05 PM Step Count 129 Switch Count 0 701 ! quit; 702 data class_import; 703 set xpt.class; 704 ;run; NOTE: There were 19 observations read from the data set XPT.CLASS. NOTE: The data set WORK.CLASS_IMPORT has 19 observations and 5 variables. NOTE: DATA statement used (Total process time): real time 0.08 seconds user cpu time 0.00 seconds system cpu time 0.00 seconds memory 443.90k OS Memory 18936.00k Timestamp 06/17/2016 06:01:06 PM Step Count 130 Switch Count 0 704 ! quit; proc cport data=sashelp.class file="d:/cpt/class.cpt"; ;run;quit; proc cimport data=classcpt file="d:/cpt/class.cpt"; ;run;quit; 711 proc cport data=sashelp.class file="d:/cpt/class.cpt"; 712 ;run; NOTE: PROC CPORT begins to transport data set SASHELP.CLASS NOTE: The data set contains 5 variables and 19 observations. Logical record length is 40. NOTE: PROCEDURE CPORT used (Total process time): real time 0.00 seconds user cpu time 0.00 seconds system cpu time 0.01 seconds memory 226.28k OS Memory 18936.00k Timestamp 06/17/2016 06:03:21 PM Step Count 134 Switch Count 0 712 ! quit; 713 proc cimport data=classcpt file="d:/cpt/class.cpt"; 714 ;run; NOTE: PROC CIMPORT begins to create/update data set WORK.classcpt NOTE: Data set contains 5 variables and 19 observations. Logical record length is 40 NOTE: PROCEDURE CIMPORT used (Total process time): real time 0.01 seconds user cpu time 0.01 seconds system cpu time 0.00 seconds memory 321.46k OS Memory 19196.00k Timestamp 06/17/2016 06:03:21 PM Step Count 135 Switch Count 0 714 ! quit;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: