+ Reply to Thread
Results 1 to 2 of 2

Thread: SAS Counting

Hybrid View

  1. #1
    Points: 8,996, Level: 63
    Level completed: 82%, Points required for next Level: 54

    Posts
    481
    Thanks
    22
    Thanked 3 Times in 3 Posts

    SAS Counting

    Hi!

    I have a database in which I'd appreciate some assistance in carefully counting some variables. Here is a sample of what I'm working with:

    Code: 
    Store ID Customer ID Date Purchased
    123         1                   01 Feb
    123         1                   02 Feb
    123         2                   01 Feb
    I'd like to count a few things:

    (a) how many unique stores do i have in my data set?

    Code: 
    I did the following:
    
    proc sort data = blah nodupkey out=blah2
    by storeid
    run;
    (b) how many distinct customers did each store ID recieve (here the answer would be 2 for the example)

    (c) how many purchases were done by each store id in general (I have a feeling I can just use a first. and last. by processing for store_id).
    Last edited by jamesmartinn; 02-21-2012 at 02:04 PM.

  2. #2
    Ninja say what!?!
    Points: 8,297, Level: 61
    Level completed: 49%, Points required for next Level: 153
    Link's Avatar
    Posts
    1,165
    Thanks
    37
    Thanked 82 Times in 75 Posts

    Re: SAS Counting

    Sorry. In a hurry. thought I'd set up the code for the first answer. The code can be edited for the remaining ones.

    Quote Originally Posted by jamesmartinn View Post
    (a) how many unique stores do i have in my data set?
    Code: 
    proc sql; create table stores as select unique(Store) from blah2; quit;

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts








Advertise on Talk Stats