Desktop productivity for business analysts and programmers

Format: Change Floating Points to Zero

Reply
Frequent Contributor
Posts: 104

Format: Change Floating Points to Zero

I have these points (or floating points?) in column Buy In, see image below.  I want to create a user defined format to change floating points tp zero because it's easier to handle them in excel.

I got the steps from this community on how to do it but it's doesn't give me what I want.  Help please.

Capture.PNG

Frequent Contributor
Posts: 104

Re: Format: Change Floating Points to Zero


Forgot to add, these are the instructions I was given on this site:

  1. In EG, click Tasks->Data->Create Format to start the
    Create Format task (or you can just submit the code below, similar to what the
    task will generate)
  2. Give the format a name (ex. "MissingLabelFmt")
  3. Check Specify
    format width
    and give it a reasonable width (ex. 12)
  4. On the Define Formats page, click New
  5. Specify your desired label (ex. "Other" or
    "Missing")
  6. In the Range definition area, select Missing values in the
    Values dropdown
  7. Run the task

After
creating the user-defined format, apply it to your column...

  1. In the EG Query Builder (where you did the join), on the Select Data tab,
    double-click the MarketingZone variable
  2. Click the Change
    button next to the Format field
  3. Click the User Defined category and select the format you
    defined (ex. $MISSINGLABELFMT.)
  4. Click Ok, Ok, then Run
Super User
Posts: 11,134

Re: Format: Change Floating Points to Zero

What do you mean by "change floating point to 0"? do you mean to no display the decimal part or to remove any decimal part? A format like F4.0 would not display any decimal. If you still want $ to appear then try a format like dollar6.0.

To change the value round with the Round function.

Frequent Contributor
Posts: 104

Re: Format: Change Floating Points to Zero

I would like to change any rows with decimal point to zero.  I would I do that . Thanks

Super User
Posts: 11,134

Re: Format: Change Floating Points to Zero

I'm not sure I understand. If the current value is 100.00 you want to display 0 or 100?

Frequent Contributor
Posts: 104

Re: Format: Change Floating Points to Zero

I want to the missing values which SAS display as a point.  I want those missing values to display zero. Sorry for the confusion.

Super User
Posts: 11,134

Re: Format: Change Floating Points to Zero

I don't use EG. This code generates a format that does what I think you are asking for:

proc format library=work;

value mydollar

. = '$0'   /* if you don't want $ to appear then just '0'*/

other=[dollar8.2]   /* what ever the current format you are using for that column goes inside [ ]*/

;

run;

Assign the MYDOLLAR format after it is created to the column(s) needed.

If you have a mixture of desired output like $ format and simple format like F4.2 you would need a separate format for each.

Frequent Contributor
Posts: 104

Re: Format: Change Floating Points to Zero

I followed your steps and the Program runs but I couldn't find the format in the assigned work.query dataset.

Frequent Contributor
Posts: 104

Re: Format: Change Floating Points to Zero

These are the codes I inputted in Program

Capture.PNG

Super User
Posts: 11,134

Re: Format: Change Floating Points to Zero

Just the library. I would expect to get an error work.query...

The format would be the WORK library. I would expect that just going to assign format method you should be able to find MYDOLLAR in the list of available formats, or type in the name of the library.

Frequent Contributor
Posts: 104

Re: Format: Change Floating Points to Zero

It was helpful.  Thank you.

Ask a Question
Discussion stats
  • 10 replies
  • 530 views
  • 3 likes
  • 2 in conversation