BookmarkSubscribeRSS Feed
smadlindl0
Calcite | Level 5

Hey! 

This is my code up to now:

 

proc freq data=123;
table issr_id;
where def=1;
run;

 

I want to know the total number of issr_id with the condition def=1.

But the Problem is, there are some issr_id with have more then one def=1.

 

How can I get the total number of issr_id with def=1, without issr_id with the same number are counted muliple times? 

 

 

Hope you get my question.

Thanks!

4 REPLIES 4
LinusH
Tourmaline | Level 20
Not sure what you actually will count the frequency on.
What does uniquely identifies row in the input table?
Data never sleeps
JediApprentice
Pyrite | Level 9

It sounds like you're trying to get a frequency of unique issr_ids. Am I correct in assuming this? If so, before you do the proc freq, you could use PROC SQL and select distinct issr_ids, or a datastep and use by group processing to filter out issr_ids that are identical. Hope this helps.

 

Astounding
PROC Star

It sounds like you are looking for just a single number as the output.  If so, this might do it:

 

proc sql;

select count(distinct(issr_id)) from have where def=1;

quit;

 

 

Ksharp
Super User

Then pick up the first obs wthin each group firstly.

 

proc sort data=123 out=_123 nodupkey;
 by def;
run;

proc freq data=_123;
table issr_id;
where def=1;
run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 900 views
  • 0 likes
  • 5 in conversation