SAS Programming - calculations on class Interval based data

Posted on 2006-03-31
Last Modified: 2010-04-17

How do we input and run procedures
 on a class interval based data for example

Class Interval                             Frequency
    0-2                                              1
    3-5                                              3

etc. If I want to run proc Univariate on this to calculate basic stats
then how will I do that

Question by:anshuma
    LVL 4

    Expert Comment

    First, I would create a variable which would indicated which interval you wanted

    In your example

    if classinterval < 3 then classind = 1; else
    if classinterval < 6 then classind  = 2;    /* etc */

    If you have a lot of these, I would recommend the SELECT statement

    SELECT (Classinterval);

    when (0..2) classind=1;
    when (3..5) classind=2;

    Then run proc univariate with the classification variable indicated.


    Author Comment

    I am sorry but I couldn't figure it out. Could please send me the code

    This is the data

    0-2      1
    3-5      3
    6-8      5
    9-11      4
    12-14      2

    I tried creating the following code

    data temp1;
    set sasuser.EX3_29;

    CLASS classind;

    EX3_29 is the sasdata set with following properties

    -----Alphabetic List of Variables and Attributes-----
    # Variable Type Len Pos Label
    1 Class_Interval Char 255 8 Class_Interval
    2 Frequency Num 8 0 Frequency

    LVL 4

    Accepted Solution

    I do not think that I understand the problem.  If your data only consists of class interval and frequency, what stats are you hoping to produce?

    The thought the problem was that you had data on some measure like taxes, for example and you class interval was based on, say, income class and you wanted to know averages, totals, etc of tax by income class.

    From your reply, its sounds like frequencies have already be calculated for your classes and you are not interested in any other variable, so I am not sure where you are going from here.

    If I have a better understanding, I am confident that I can help.

    -- tobydavid

    Author Comment

    I am sorry for being so late. I hope that you won'd mind this. I will post the question soon albeit with more explaination.


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    INTRODUCTION We all know how to code. But at times you simply want to insert a common code block into your existing code and amend it as per your requirements. This tool not only saves you time but also saves you the pain of typing it all out aga…
    This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now