[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SAS proc freq counting

Posted on 2009-12-16
4
Medium Priority
?
979 Views
Last Modified: 2013-11-16
What SAS code do I add to this statement to get back info only for instances where ID count > 1?   I've already sorted the file by ID.  
proc freq data=combined_03;
	by ID;
	tables TYPE RESULT / NOPERCENT;
run;

Open in new window

0
Comment
Question by:dhssra
3 Comments
 
LVL 18

Assisted Solution

by:Cory Vandenberg
Cory Vandenberg earned 248 total points
ID: 26081247
Check out the following link.

http://www2.sas.com/proceedings/sugi30/263-30.pdf

I believe you may be able to do what you want by creating an output dataset, then printing that dataset with a WHERE clause that only prints COUNT > 1.

Something like the code below.

WC
proc freq data=combined_03 noprint; 
        by ID; 
        tables TYPE RESULT / NOPERCENT out=freq_results; 
run;

proc print data=freq_results;
  where COUNT > 1;
run;

Open in new window

0
 

Accepted Solution

by:
tquakenbush earned 252 total points
ID: 26081669
I've attached some code that does some pre-processing of the data prior to the Proc Freq.

1) creates a temporary table with the count of IDs
2) delete those with count = 1
3) create a temporary table from combined_03 with only those IDs with count > 1
4) Proc Freq the table from step 3)
* create temp table with count by ID;
proc freq data=combined_03 order= freq; 
        tables ID / nopercent noprint out= ID_count; 
run;

* delete those IDs with count= 1;
data ID_count (keep= ID);
	set ID_count;
	if count = 1 then delete; run;

* create temp table with records for those IDs with count more than one;
data merge_for_freq;
	merge combined_03 (in= a) ID_count (in= b);
	by ID;
	if a and b;
run;

proc freq data=merge_for_freq; 
        by ID; 
        tables TYPE RESULT / NOPERCENT; 
run;

Open in new window

0
 

Author Closing Comment

by:dhssra
ID: 31667063
Solutions work, and process in about the same length of time.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this article, we’ll look at how to deploy ProxySQL.
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

834 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