(1) I have a column of data that looks has either a positive amount or a negative number. The data is suppose to be formatted 12.2
For example:
FRED 000002300086
BARNEY -99999999999
Fred's amount = 23,000.86 and
Barney's amount = -99999999.99
The Variable Name that I am having trouble with is: TotalRewardCash shown below.
(2) A second question I have is the Variable PeriodId is yyyymmdd and I would like to read it in as a date, but couldn't find an ebcdic format that would work properly.
DATA CCARD_RAW_DATA;
INFILE COMMCARD;
INPUT
@1 ReferenceNumber $EBCDIC12.
@13 CustomerID $EBCDIC12.
@25 BankId $EBCDIC12.
@37 PeriodId $EBCDIC8.
@135 TotalRewardCash S370FZDU12.2 ;
RUN;
I have tried many informats but this one gets me the closest. It brings in the numbers but will not bring in the leading negative sign.
I have tried S370FZDL12.2 but then I get nothing.
Does anyone have any suggestions?
Thanks.
Update...
I got it to work... The INFORMAT can be 12.2 but then I need to FORMAT it bigger.... 14.2 to fit the decimal sign and the leading minus sign... YAY!!!
When you are running this code in a mainframe you do not the $EBCDIC coding the $ coding will do as Ebcdic is default in z/OS.
When you have downloaded the file binary, beware of record formats. Sometimes you get trapped by cr/lf characters as part of numeric values.
There are several dedicated numeric formats at z/OS.
- floating often not used with Cobol.
- packed (with signs) the two digits are getting compressed by their hexadecimal representation
- Zoned (with signs) the digits are not compressed but the last digit is with the sign.
- character based. Similar to zoned but not having signs. It is more a constraint on some values on the used chars.
You have used the unsigned zoned type. No wonder you no signs
SAS(R) 9.4 Formats and Informats: Reference S370FZDw.d Informat is most common. Watch the notes on the used Cobol Picture. When you know that one you are sure wich format to be used.
I am not using Mainframe SAS to read the file. I use Enterprise Guide interface and read the Mainframe file via FTP statement. That is why I need to use the EBCDIC informats to read my data in. Otherwise I get gibberish.
I have tried all of the file formats listed and none of them get me the desired results.
I will review the website to see if I missed any. Thanks anyway..
Update...
I got it to work... The INFORMAT can be 12.2 but then I need to FORMAT it bigger.... 14.2 to fit the decimal sign and the leading minus sign... YAY!!!
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.