Posted on 2011-04-29
Last Modified: 2013-11-16
Hi,  Does anyone know if I can run a proc freq on part of a string, like the first 3 characters?  
Question by:Wonderwall
    LVL 9

    Accepted Solution

    You can't use PROC FREQ unless you add a field prior to running the PROC FREQ containing the first three chars.  Ex:
    DATA YourDataset;
    SET YourDataset;
    LENGTH First3 $3.; First3=SUBSTR(FieldYourWantToFREQOn,1,3);

    PROC FREQ DATA=YourDataset;
    TABLE First3 /MISSING;

    OR if you want to do this without creating a new field, you might be able to get it done using PROC SQL.  Ex.
    SELECT SUBSTR(FieldYourWantToFREQOn,1,3) AS First3, COUNT(*) AS Obs
    FROM YourDataset
    GROUP BY First3;

    Author Comment

    Thank you, That worked like a charm!!!!!

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    This article describes some very basic things about SQL Server filegroups.
    Creating and Managing Databases with phpMyAdmin in cPanel.
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    730 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

    16 Experts available now in Live!

    Get 1:1 Help Now