All YOUR Questions Answered at
[sas.answers @ Holland Numerics]
WebRing
Sponsored Links for SAS Software Users
Careers, Jobs and Contracts, Services and Products

Formats and Informats

Question Answer
I'm reading a VSAM file and getting an amount field from a record. The amount field is
COBOL 9(9)V99

but is held on the file without the decimal point, so, on the file you may have 00000000592 which is £5.92. Unfortunately, I'm having great difficulty in reporting against this field as everything either appears as '592' or '592.00', whereas '5.92' would be great! I'm using

INPUT amount 338-348;

to read the data, based on position.

I found this gem of information in the SAS Language Reference manual, p407-409. Try:
INPUT amount 338-348 .2;
I've got some dates stored as
1923
968c

in hex.
I'm reading them in using an informat of PD4. How do I get to display them out in say, DDMMYY. format? I've played with the JULIANw in/format with little joy.

You need to use a SAS function to convert the numeric Julian date to a SAS date, so:
(1) Read the following data with PD4.
1923
968c ----> 1996283

(2) Convert the numeric value with the DATEJUL function

DATEJUL(1996283) ----> 13431 (ie. 09OCT1996)
I've got a time stored in a VSAM files as PIC S9(7) COMP-3. I'm reading it using PD4. so I get '012433'. I am displaying it using a format of Z6. What would be terrific would be to get '01:24:33'. Try the PICTURE statement in PROC FORMAT, like this (see 'SAS Procedures Guide', Version 6, 3rd Edition, p287-312):
PROC FORMAT;
  PICTURE COLONS LOW-HIGH='99:99:99';
RUN;
DATA test;
  x=12433;
  PUT x= COLONS.;
RUN;
Can SAS software cope with Euros? Yes. In SAS v6.12 there is an add-on download which adds a number of formats and informats that will convert the following European currencies to and from Euros:

Fixed exchange rates: ATS, BEF, DEM, ESP, NLG, FIM, FRF, IEP, ITL, LUF and PTE.

Variable exchange rates: CHF, CZK, DKK, GBP, GRD, HUF, NOK, PLZ, ROL, RUR, SEK, SIT, TRL and YUD.

The formats and informats, EURTOxxx. (to convert from Euros to another currency) and EURFRxxx. (to convert to Euros from another currency), are incorporated in Base SAS v8.0 and v8.1, and preliminary documentation can be found on the SAS web site at www.sas.com/rnd/base/. Full documentation should be included in the standard documentation with SAS v8.2.

How do you update the variable exchange rates to the Euro? The fixed exchange rates cannot be altered, but the variable exchange rates can be updated by using the EURFRTBL filename. Create a file containing the correct exchange rates to Euros, e.g.
FILENAME eurfrtbl '&euro_rate';
DATA _null_;
INPUT;
FILE eurfrtbl;
PUT _INFILE_;
CARDS;
eurfrgbp=0.62
eurfrchf=1.51
;
RUN;
The variable exchange rate EURTOxxx. and EURFRxxx. formats and informats will now use any updated values you have specified, provided the temporary text file is still allocated to the EURFRTBL filename.
I'm trying to get the 'amount' fields to display values in pounds (£), but all I get is ($) - I can't figure out how to do it ! I'm using a format of
FORMAT amount DOLLAR16.2;

There doesn't seem to be a way of using POUND instead. Is there a sneaky option I need to use ?

You're right it doesn't work in SAS 6.11/6.12 on the PC, but it does 'work' on 6.08 on the mainframe, as the '$' symbol there has been replaced by the '£' symbol... So, on the PC, try creating your own SAS Format, say POUNDB17.2 or POUNDN16.2, using PROC FORMAT and the PICTURE statement, e.g.
PROC FORMAT;
  PICTURE POUNDB LOW-<0='000,000,000.00)' (PREFIX='(£')
                 0-HIGH='000,000,000.00 ' (PREFIX='£');
  PICTURE POUNDN LOW-<0='000,000,000.00' (PREFIX='-£')
                 0-HIGH='000,000,000.00' (PREFIX='£');
RUN;

     Back to Main FAQ Menu