DATA Step, Macro, Functions and more

How do I get the frequency of a constant accross all variables

Reply
New Contributor
Posts: 3

How do I get the frequency of a constant accross all variables

i am trying to see how many customers (by SSN) have applied for credit accross multiple customers/stores.  Each store has a unique ID and each SSN is unique.  I am using Enterprise Guide 5.1 and feel I shold use a Proc Freq but I need to see which unique SSN matches to more than on unique store_ID. 

 

Is this possible with a Proc Freq or some other statement? 

SAS Super FREQ
Posts: 8,864

Re: How do I get the frequency of a constant accross all variables

Posted in reply to James_Littlejohn
Is all this information in one dataset? Or is the data in more than 1 dataset? How is the data structured? Do you have one row for every unique SSN or can you have multiple SSN rows? Does each person/SSN have one column for their store IDs or .... ? How/whether you use PROC FREQ will depend on the answer to how the data is structured.

cynthia

cynthia
New Contributor
Posts: 3

Re: How do I get the frequency of a constant accross all variables

Posted in reply to Cynthia_sas

All of the data is in one dataset.  There is a column for Store_ID and another for SSN.  There are many dupllicates for both of these variables and I am trying to find the ssn's that are common in more than one store.

 

There is a unique record for each credit application that a customer fills out.  I want to see how many stores they apply to.  I de-duped by SSN and took the last record but that only gave me the store they applied for on the last application.

Super User
Posts: 5,498

Re: How do I get the frequency of a constant accross all variables

Posted in reply to James_Littlejohn

A single PROC FREQ won't do it, but two PROC FREQs will.  The idea is that the output from the first PROC FREQ becomes the input to the second PROC FREQ:

 

proc freq data=have;

tables ssn * store / noprint out=unique;

run;

 

proc freq data=unique;

tables ssn / noprint out=want (keep=ssn count where=(count > 1));

run;

 

This gives you a final data set named WANT, with SSN and COUNT.  COUNT is a count of how many different stores that particular SSN applied at.

 

I'm sure there are some clever SQL programmers out there that could do this in one step. But with PROC FREQ it takes two.

New Contributor
Posts: 3

Re: How do I get the frequency of a constant accross all variables

Posted in reply to Astounding

That worked perfectly, thank you.  I now need to isolate the last applications for each customer for each store.  I have de duped by last.app_id but that only gives me one record per customer.  If the customer applied at 4 stores, I want to keep the last application entered (these are numerical) for each customer by store.  If the customer went to 1 store, they would have 1 record, 4 stores 4 records etc.

 

I am trying to sort by store name ascending application numb er, then take the last ssn for each store but am not getting success..

Super User
Posts: 5,498

Re: How do I get the frequency of a constant accross all variables

Posted in reply to James_Littlejohn

It sounds like  you are moving in the right direction.  Try using three variables in your BY statement:

 

by store ssn application_no;

 

Then condition on last.ssn.

 

Alternatively:

 

by ssn store application_no;

 

Then condition on last.store.

Ask a Question
Discussion stats
  • 5 replies
  • 260 views
  • 0 likes
  • 3 in conversation