I'm having a dandy of a time recognizing a simple .XPT file from the CDC. The code I am using is this:
libname xptfile xport 'folders/myfolders/LLCP2014.XPT ';
libname sasfile '/folders/myfolders';
I have the LLCP2014.XPT file in my shared folder, and have full permissions on it for use with SAS University Edition. These commands run successfully, but there is NO .sas7bdat file ever created in any library.
I've never had this problem before, and have completed a full research study using this method. Any ideas?
This is how I am trying to access the newly created dataset, but nothing is there.
data tmpb2014;
set xptfile.LLCP2014;
run;
I figured it out. The filename, when unzipped, automatically puts a space at the end of .XPT, which causes SAS to ignore it and misreport the size/format. Wow....bad job, Apple.
There are two issues with the code you posted.
Your first LIBNAME is using a relative path instead of an absolute path. That will not work since the default directory is NOT the root node.
Your data step is create a work dataset only. So you never TRIED to write any SAS datasets back to your shared folder, which would explain why they aren't there.
The first is probably just a typo since you said the code ran.
For the second one you just need to change your output dataset name in the DATA statement to use the libref you defined in your second LIBNAME statement. Or add another step to save it.
data sasfile.tmpb2014;
set xptfile.LLCP2014;
run;
Can you show your log?
XPORT engine does not support some SAS 9 features such as long variable names and should show warnings if that is the issue.
You might need to investigate Proc Cimport if the transport file was built using Proc Cport.
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 *Objective:
74
75 The objective of this analysis is to investigate the association between depression
76
77 (yes versus no) and general health (Excellent/Very good versus good/fair/poor)
78
79
80 after adjusting for gender and education in 2014 BRFSS data;
81
82 libname xptfile xport 'Users/abbyjones/Documents/myfolders/LLCP2014.XPT';
NOTE: Libref XPTFILE was successfully assigned as follows:
Engine: XPORT
Physical Name: /opt/sasinside/SASConfig/Lev1/SASApp/Users/abbyjones/Documents/myfolders/LLCP2014.XPT
83 libname sasfile '/folders/myfolders';
NOTE: Libref SASFILE was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders
84
85 data sasfile.tmpb2014;
86 set xptfile.LLCP2014 (where=((ADDEPEV2 in (1, 2)) and (GENHLTH in (1, 2, 3, 4, 5))
87 and (educa in (1, 2, 3, 4, 5)) ));
ERROR: Physical file does not exist, /opt/sasinside/SASConfig/Lev1/SASApp/Users/abbyjones/Documents/myfolders/LLCP2014.XPT.
88
89
90 if ADDEPEV2 in(1) then
91 Depressed=1;
92 *yes;
93
94 if ADDEPEV2 in(2) then
95 Depressed=0;
96 *no;
97
98 if GENHLTH in (1, 2) then
99 hlthcat=1;
100 *excellent or very good reported health;
101
102 if GENHLTH in (3, 4, 5) then
103 hlthcat=0;
104 *good, fair, or poor reported health;
105
106 if EDUCA in (1, 2) then
107 educat=1;
108 *'Less than 8';
109
110 if EDUCA in (3, 4) then
111 educat=2;
112 *'9-12/GED';
113
114 if EDUCA in (5, 6)then
115 educat=3;
116 *'College/Prof. Degree';
117 run;
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set SASFILE.TMPB2014 may be incomplete. When this step was stopped there were 0 observations and 6 variables.
WARNING: Data set SASFILE.TMPB2014 was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
118
119 *table1;
120
121 proc freq data=tmpb2014;
122 tables (sex educat) *hlthcat / chisq;
ERROR: Variable SEX not found.
123 run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
124
125 *table2;
126
127 proc freq data=tmpb2014;
128 tables (hlthcat sex educat) * Depressed / chisq;
ERROR: Variable SEX not found.
129 run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
130
131 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
143
It was built using PROC XPORT, and even comes with a prebuilt XPORT SAS file that I cannot get to work on my MAC. Again, I've done this many times and never had a problem with relative paths. I used shared drives on the appliance before with no problems.
The LIBNAME statement in your first post is much closer to being right than the version in your log.
There is no "User" folder on the unix virtual machine where SAS is running. Your files are under /folders/myfolders.
Remember that if the path does not start with a slash, / , also known as the root node, then it is a relative path. Look at how SAS interpreted the path in your SAS log.
I already tried that without success. I think what I posted was revision two. Nothing is working. Very frustrating.
That's what I've been doing. It doesn't work.
I even created a new share on the Virtual Machine, copied the paths from the properties,
libname xptfile xport '/folders/myshortcuts/brfss/LLCP2014.XPT';
libname sasfile '/folders/myshortcuts/brfss/';
I've done it both ways, with the trailing / on the sasfile statement and without it.
, and this is what I have, but the dataset is empty, so at least it is creating it here.
And this is how I am accessing it:
I continue to get
ERROR: Physical file does not exist, /folders/myshortcuts/brfss/LLCP2014.XPT.
If you are using SAS University Edition then it is probably something like:
/folders/myfolders/brfss/LLCP2014.XPT
"Folder Shortcuts" is just how the GUI shows it, so I doubt that "myshortcuts" is actually part of the path.
That screen shot is showing that you have defined brfss as a shortcut that points to an actual directory on the virtual machine. So the above example I typed might not be right. You might has defined "brfss" as a pointer to some other path like: /folders/myfolders/My Sub Folder/BRFSS
But if you select that file name that represents the XPT file in that GUI interface and select properties what path does it show? That is the path you need to use, not what is shown in that screen shot.
Remember that Unix file names are case sensitive.
Perhaps this is the reason. SAS is seeing this as a 0 byte file.
I navigate to the folder and it does have the appropriate size.
I figured it out. The filename, when unzipped, automatically puts a space at the end of .XPT, which causes SAS to ignore it and misreport the size/format. Wow....bad job, Apple.
That is not Apple's fault, or ZIP either, but is caused by the creator of the ZIP file adding the space to the filename.
Hi Tom,
First off, please let me thank you and BallardW and everyone else for all of the assistance you offered yesterday. While it was a flukey thing that ended up being the culprit, I appreciate your valuable time.
On a side note, if these are the same data I used a year ago, and the files haven't been changed, it would appear that unzipping in Windows might be more effective at truncating that space. I cannot verify this as I do not have a Windows machine.
Thank all of you very much for your time and patience. I look forward to learning from you all.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.