Any SAS Programmers Out There ?

Discussion in 'Archived Threads 2001-2004' started by Alex S, Jan 23, 2002.

  1. Alex S

    Alex S Second Unit

    Joined:
    Feb 21, 2000
    Messages:
    477
    Likes Received:
    0
    Trophy Points:
    0
    A vendor sent me a file with numeric fields that he wants reports generated from.

    The first report he wants me to add 2 numeric columns up for over 250,000 accounts.

    An example of how the data is displayed is like this:

    0000000001817.86

    -000000000071.34

    The sign and decimal point is in the data.

    Can this be done by a SAS program ?

    If so how ?

    Thanks.

    Alex S
     
  2. Dave Morton

    Dave Morton Supporting Actor

    Joined:
    Oct 19, 2000
    Messages:
    753
    Likes Received:
    0
    Trophy Points:
    0
    Real Name:
    Dave
    Alex,

    I've been programming in SAS for 10 years and yes, you can do that. SAS will discard the preceding 0's or else it will think the column is character and you have to change it to numeric by adding a 0. So your code would look like this:

    newvar=oldvar+0;

    Then to sum up the columns you can use the following to create a data set called final with a variable called col1sum and col2sum for the sum of each column;

    proc means;

    var column1 column2

    output out=final sum=col1sum col2sum;

    run;

    proc print data=final;

    var col1sum col2sum;

    run;

    Hope this helps. Let me know if you have any other questions.
     
  3. Alex S

    Alex S Second Unit

    Joined:
    Feb 21, 2000
    Messages:
    477
    Likes Received:
    0
    Trophy Points:
    0
    Dave,
    Thank you very much !!
    [​IMG]
     
  4. Philip Hamm

    Philip Hamm Lead Actor

    Joined:
    Jan 23, 1999
    Messages:
    6,873
    Likes Received:
    2
    Trophy Points:
    0
    Proc print? Damn, that's the freekin' Stone Age. proc report roolz. Just ask Ray Pass!! [​IMG]
     
  5. Dave Morton

    Dave Morton Supporting Actor

    Joined:
    Oct 19, 2000
    Messages:
    753
    Likes Received:
    0
    Trophy Points:
    0
    Real Name:
    Dave
    Alex,

    If you want to use proc report and have trouble, I can help you too. Obviously so can Philip.

    For two numbers, it seems like you only really need the output from the means statement.

    Personally I use either proc report or a data null step to fully control and customize my reports if proc report can't do it.

    Just a matter of preference. Have fun!
     

Share This Page