data step to read these data into three variables: Invoice, Amount, and Quantity.
12244 $1,499.99 144
32189 $20,000 1
92314 49.28 3
I have written the below code
data testrun;
input invoice amount quantity;
informat amount dollar9.2;
cards;
12244 $1,499.99 144
32189 $20,000 1
92314 49.28 3
;
run;
There is no errors in log but it is reading all observations.but it is not correct, What is the problem. Thanks for the help
dollar9.0
Adding “$” in front of 49.28 for amount fix the problem. I think I you specify the dollar format all of you fields needs to have dollar($) sign.
data testrun;
input invoice
amount dollar9.2
quantity ;
format amount dollar9.2;
cards;
12244 $1,499.99 144
32189 $20,000 1
92314 $49.28 3
;
run;
proc print data=testrun;
run;
A missing $ sign is NOT the problem. Do you think $20,000 is twenty thousand or $200.00?
It's $20,000 twenty thousand
What DATA_NULL_ is trying to point out is that for an INFORMAT the decimal part of the informat is the number of decimal places to apply when the value read does NOT contain a decimal point. When you specify dollar9.2 you are telling SAS to divide the 20,000 value by 100 in order to implement the implied decimal place.
Use dollar9.0 for the informat.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.