The SAS Output Delivery System and reporting techniques

A question about base SAS~from a new SAS user

Reply
N/A
Posts: 0

A question about base SAS~from a new SAS user

Dear all,
I tried to output the below data but kept getting errors. Could somebody help me? Thanks a lot.
I attach my code as well.

12244 $1,499.99 144
32189 $20,000 1
92314 49.28 3

data temp;
input Invoice 5. Amount dollar26.2 Quantity ;
format Invoice 5. Amount dollar26.2 Quantity;
cards;

12244 $1,499.99 144
32189 $20,000 1
92314 49.28 3
;
proc print;
run;
Super Contributor
Posts: 358

Re: A question about base SAS~from a new SAS user

Posted in reply to deleted_user
Penny:

Try this - there are minor changes:

data temp1;
input Invoice 5. Amount Quantity ;
format Invoice 5. Amount dollar26.2 Quantity 5.;
cards;
12244 1499.99 144
32189 200.00 1
92314 49.28 3
;
proc print;
run;
SAS Super FREQ
Posts: 8,862

Re: A question about base SAS~from a new SAS user

Posted in reply to deleted_user
An alternative to changing your data is to use the colon modifier to read the data using a specific informat.

You show your data with dollar signs, which are invalid in a number (valid for formats, but invalid for reading with the standard numeric format.)

So, instead of this:
input Invoice 5. Amount dollar26.2 Quantity ;

you would have
input Invoice 5. Amount : comma26. Quantity ;


The nice thing about the comma informat is that it detects dollar signs, commas and decimal points and essentially strips the dollar signs and commas from the number before storage. (It also deals with parentheses, percent signs and dashes, etc.)

If you have any more problems reading your data, your best bet might be to contact Tech Support, as there are other issues you might run into or need to put into your program (such as an INFILE statement that points to a data file instead of a CARDS statement with in-line data or an INFORMAT statement).

Also, even if you want your formatted length to be 26.2, you do NOT have to read the data with that same informat. Sometimes, specifying a decimal place holder when you read a number could cause the insertion of a decimal point where you don't want it. You have to be certain that ALL the numbers in your file have a decimal point in order to use an informat with a decimal indicator.

To find out how to contact Tech Support, refer to this site: http://support.sas.com/techsup/contact/index.html

Good luck!
cynthia
N/A
Posts: 0

Re: A question about base SAS~from a new SAS user

Posted in reply to Cynthia_sas
Thanks a lot for your help!!!!!!
Ask a Question
Discussion stats
  • 3 replies
  • 154 views
  • 0 likes
  • 3 in conversation