BookmarkSubscribeRSS Feed
juju_p
Obsidian | Level 7

Hello,

 

I have converted some XPT files into SAS . The XPT files were downloaded from CASTOR EDC and encoded in UTF-8.

 

After conversion I cannot open my SAS files there is an error message 'SAS format could not be found or loaded...' (see attached doc)

 

Formats are available in a file called formats.sas7bcat. If I could import that file in my work environment, will be able to open the SAS files?  If so, how could I do the import?

 

 

 

Kind Regards

 

Justine

4 REPLIES 4
Tom
Super User Tom
Super User

To let you use the data without the special formats just tell SAS to ignore the missing formats by setting the NOFMTERR option.

If you have a format catalog then you can try to use it.  (Note you do not "import" a format catalog anymore than you import a SAS dataset, you just use it as it is already a SAS file.)  But remember that format catalogs are specific to the version of SAS and the type or operating system you are using.  So the format catalog might be useless.  If they used a transport file for the dataset then they should have used a transport file for the catalog also.  It is hard to tell from your description what type of transport file you got for the dataset (the XPT extension is not tied to any particular type of file).  If it was a file created by PROC CPORT then it could contain format catalogs in addition to datasets.  But the version 5 XPORT format created by the XPORT libref engine (or the newer verison created by the SAS supplied macros) cannot contain catalogs.

 

To test the catalog place it one the computer where SAS is running and point a libref at the directory ("folder") where the catalog file lives.  So if the file is named xxx.sas7bcat and your libref was named MYFMT then you could try running PROC FORMAT to see what is in it and test if SAS can use it.

proc format lib=myfmt.xxx fmtlib;
run;
Ksharp
Super User
You could try this option:


libname x v9 'c:\temp\';
options fmtsearch=(x);
andreas_lds
Jade | Level 19

The encoding of your sas session is utf-8, right?

Emma_at_SAS
Lapis Lazuli | Level 10

@juju_p  You may try adding options=nofmterr; in the data step when you read your data file to avoid that format error.

libname mylib "c:\the path to your data file";

data mydata;

set mylib.datafilename;

options=nofmterr;

run;

Then import your format file in LIBRARY. 

libname library "c:\path to your format file";

Then you can access the value labels in your PROC steps.

proc freq data=mylib.mydata;

tables var1;

run;

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 4 replies
  • 4782 views
  • 1 like
  • 5 in conversation