BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
abbyrjones72
Obsidian | Level 7

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
abbyrjones72
Obsidian | Level 7

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.

View solution in original post

22 REPLIES 22
Tom
Super User Tom
Super User

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;

 

 

ballardw
Super User

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.

abbyrjones72
Obsidian | Level 7
 
 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        
abbyrjones72
Obsidian | Level 7

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. 

Tom
Super User Tom
Super User

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.

abbyrjones72
Obsidian | Level 7

I already tried that without success. I think what I posted was revision two. Nothing is working. Very frustrating.

Tom
Super User Tom
Super User
Find the file in the Files and Folders tab. Open properties of the file to find the path and copy and paste it into your code.
abbyrjones72
Obsidian | Level 7

That's what I've been doing. It doesn't work.

abbyrjones72
Obsidian | Level 7

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.

 

Screen Shot 2019-01-15 at 4.23.35 PM.png

 

And this is how I am accessing it:

Screen Shot 2019-01-15 at 4.24.51 PM.png

 

I continue to get 

ERROR: Physical file does not exist, /folders/myshortcuts/brfss/LLCP2014.XPT.

 

Tom
Super User Tom
Super User

 

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.

abbyrjones72
Obsidian | Level 7

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.

Screen Shot 2019-01-15 at 7.53.59 PM.png

abbyrjones72
Obsidian | Level 7

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.

Tom
Super User Tom
Super User

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.

abbyrjones72
Obsidian | Level 7

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.

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 22 replies
  • 2907 views
  • 2 likes
  • 4 in conversation