BookmarkSubscribeRSS Feed
Tom
Super User Tom
Super User

@Reeza 

So the problem with your first XPT file is that HAVEN put binary zeros into the FORMAT and INFORMAT name fields on the V8 NAME records instead of spaces.

 

You can fix the XPT2LOC macro to read that file if you just add in code to convert the binary zeros to spaces after they are read.

...
        format   = input(substr(buffer,pos, 8),$ascii8.);   pos+8;
...
        informat = input(substr(buffer,pos, 8),$ascii8.);   pos+8;
...
        format=translate(format,' ','00'x);
        informat=translate(informat,' ','00'x);

Tom_0-1697402103287.png

 

 

Another issue I have seen is someone sent a file that had bare $ as the FORMAT or INFORMAT specification in the V9 LABEL record.  For those I just blanked them out.

...
        format=substr(buffer,name_len+label_len+1,fmtname_len);
        informat=substr(buffer,name_len+label_len+fmtname_len+1,infmtname_len);
if format='$' then do;
  putlog 'WARNING: Removing invalid ' format=:$quote. 'from variable ' name;
  format=' ';
end;
if informat='$' then do;
  putlog 'WARNING: Removing invalid ' informat=:$quote. 'from variable ' name; 
  informat=' ';
end;

 

jlt10f
Fluorite | Level 6
Thanks. I passed on this suggestion. I will follow up with any progress on it.
AhmedAl_Attar
Rhodochrosite | Level 12

@jlt10f 

If your R software and SAS software reside on the same machine (server/desktop/laptop), then this paper Using the R interface in SAS ® to Call R Functions and Transfer Data  might provide you with an alternative to your current export approach.

 

Hope this helps,

Ahmed

jlt10f
Fluorite | Level 6
I think this is a good idea but there are not many R users in the organization and I think they want a more universal solution for people who are not R users.
ballardw
Super User

Perhaps instead of writing XPT from R a simple CSV file? If the file is of the same structure a data step would read that easily if people aren't understanding how XPT files are to be used.

 

IIRC the XPT file format came about when SAS supporting a much larger number of computer operating systems that basically did not talk to each other much and predates the desktop PC versions. So it was expected that a little bit of code to run on the receiving end was acceptable, not just "click and use" a file.(Predates mouse clicks for most OS as well).

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 19 replies
  • 1638 views
  • 6 likes
  • 5 in conversation