User formats and Base SAS

Reply
Contributor
Posts: 20

User formats and Base SAS

Hi

 

I have a number of users that have a local install of Base SAS on their machines. They access datasets on a shared drive. The rest of the users use Enterprise Guide. Some of the datasets are created using user defined formats. Enterprise Guide users have no issue accessing these formats but the Base SAS users cannot access them and when opening the dataset using the formats they get the error below. I have tried setting up a library in Base SAS that contains the formats and is loaded at start up but this does not work. What is the best way to set up user formats in Base SAS.

Super User
Posts: 5,256

Re: User formats and Base SAS

The format concept in SAS is extremely well documented.

I suggest that you start in Base SAS documentation, concept guides.

As a quick fix, add -NOFMTERR to the users config files.

Data never sleeps
Respected Advisor
Posts: 3,890

Re: User formats and Base SAS

You also need to add the library to the FMTSEARCH system option so that SAS is looking there for the formats.

SAS(R) 9.3 System Options: Reference, Second Edition

Just thinking a bit further:

It appears that you can modify the .cfg and autoexec used by your PC SAS users. I assume as well that the formats accessible by your EG users are stored in a permanent library which gets assigned via Metadata.

2 alternative approaches:

1. If the format catalog is not too big then you could issue a PROC CATALOG in the autoexec which copies the formats from the library the EG users access to the catalog in WORK of the PC SAS users. That's a bit of overhead every single time the users start up PC SAS but it would avoid to assign a library.

2. If most of the libraries the EG users are using point to network drives also accessible by PC SAS users (so: from their workstation) then you could amend the autoexec so that the PC SAS sessions connect to the SAS Metadata Server (options: metaport, metaserver, metauser,....).

You would need to define a new metadata user for PC SAS and then only give read metadata for the libraries accessible from the user's workstation.

Not sure how you implemented the startup of PC SAS. The way I would go is to have an additional autoexec on a network drive accessible both from the Server where EG runs as well as from the workstations where PC SAS runs. I would then define all common settings for EG and PC SAS in this autoexec and %include it into the initial autoexec (and the same also for .cfg). That's then the place where you define stuff like FMTSEARCH and SASAUTOS.

Going down this path would allow you to keep the EG and PC SAS environment as close as possible (so that code becomes "interchangeable") while maintaining the environment centralised.

New Contributor
Posts: 3

Re: User formats and Base SAS

Hi I am new to SAS and just learnt the format and informat function. I have a small query. As we know SAS can read only upto 12 digits by default and greater than 12 digits it will convert it into exponential form. However, if I have to read my credit card number which is 16 digits in length without converting it into exponential form how do I read it or my bank account number which is greater than 12 digits or any large number greater than 12 digits without converting it into exponential form

Need your input

Super User
Posts: 17,819

Re: User formats and Base SAS

You should post this as a new question rather than a question from 2013.

The answer is to read it in as text.

New Contributor
Posts: 3

Re: User formats and Base SAS

Hi Reeza,

Thanks for replying.. Can you give me the format or syntax or an example

Super User
Posts: 17,819

Re: User formats and Base SAS

Post a new question with a sample of your data/issue.

Super Contributor
Posts: 644

Re: User formats and Base SAS

Reeza is right.

Although SAS (and most other applications running on Windows or Unix/Linux, that use the IEEE specification of 'real' numbers) can handle up to 15 digit integers, and most 16 digit integers, numbers over 9000000000000000 can suffer from a lack of precision.

Type your credit card number into Excel using a format that displays all the digits and you will see (at least in my version) the final digit converted to a zero (without warning!), which is Excel's way of only showing the digits it can guarantee the accuracy of.  I have seen a business process fail because of this happening.

Richard

New Contributor
Posts: 3

Re: User formats and Base SAS

Hi Richard,

Thanks for replying. however, I found a work around for it. You can actually input your 16 digit credit card number into SAS without it converting it into exponential form. In order to read any number greater than 12 digits use informat variablename :range. i.e say informat ccno :30. and to print it say format cc no :30. or you can also use format bestn. where n can be any value greater than 12. For example try executing this program

data abc;

input ccno;

informat ccno :30.;

format ccno:30;

datalines;

1234567890123456

3456789012345678

;

proc print;

run;

Execute it and let me know if it works. Instead of format ccno :30. you can also use format best32.

Respected Advisor
Posts: 3,890

Re: User formats and Base SAS

As others already wrote:

- SAS uses 8 bytes for numeric values. This allows you to store 15 digits and most 16 digits strings with full precision. This is the SAS internal storage of numbers.

- Formats are used to print numbers. If you don't explicitly define a format then the default will be used. If you want to print big numbers and this results in scientific notation then use a different format. SAS(R) 9.3 Formats and Informats: Reference

- Informats are used to convert a string to a numeric value. You can convert strings greater than 16 digits but you loose precision. And as SAS even can't store all 16 digits strings with full precision you can already loose precision here. And this means: change the credit card number!

- Only because a string is made up of digits doesn't mean you need to store it in a numeric variable. As a rule of thumb: Store stuff as numeric which is used for calculations, store the rest in character variables. Credit card and bank account numbers are a standard example why one needs to store such data as character and not as numbers.

Valued Guide
Posts: 3,208

Re: User formats and Base SAS

RohanPR With UE you can verify https://support.sas.com/techsup/technote/ts654.pdf  the exact number limit is given

The results are obvious

You can read as many digits as you like without getting a warning.  It just no the same number anymore.

This document is an oldie. You can also find mainframe having 2-3 bytes with different limits.

numbers well fitting in 3bytes on mainframe are fitting in Windows. This was my experience log time ago (90's) as a regions with four digits where transported and than seen them being wrong collapsed at Windows disappearing some of them. This note did not exist at that time.  

43         data abc;

44          input ccno;

45          informat ccno : 30.;

46          format ccno:30.;

47          put ccno ;

48          datalines;

1234567890123454

1234567890123455

1234567890123456

1234567890123457

1234567890123458

1234567890123459

9123456789012344

9123456789012344

9123456789012346

9123456789012368

9123456789012348

9123456789012348

12345678901234566

12345678901234568

12345678901234568

34567890123456788

Not wat was inputed.

data abc;
input ccno;
informat ccno : 30.;
format ccno:30.;
put ccno ;
datalines;
  1234567890123454
  1234567890123455
  1234567890123456
  1234567890123457
  1234567890123458
  1234567890123459
  9123456789012344
  9123456789012345
  9123456789012346
  9123456789012367
  9123456789012348
  9123456789012349

  12345678901234566
  12345678901234567
  12345678901234568
  34567890123456789
;

---->-- ja karman --<-----
Valued Guide
Posts: 3,208

Re: User formats and Base SAS

It is not only SAS. Some tried to solve this issue by elminiating SAS and using an other tool. Finding the same issue.

Single-precision floating-point format - Wikipedia, the free encyclopedia   Should belong to the knowledge of those understand digital age

---->-- ja karman --<-----
Ask a Question
Discussion stats
  • 11 replies
  • 421 views
  • 0 likes
  • 7 in conversation