mr_nbr id
123 001
123 002
234 003
456 004
456 005
456 006
how to show that mr_nbr 123 has 2 different id's,456 has 3 different id's
and how to display that out of 3 different mr_nbrs there are 2 mr_nbrs that have different id's i.e 60% have multiple id's and reverse i.e how id and mr_nbr related
data have;
input mr_nbr id $;
cards;
123 001
123 002
234 003
456 004
456 005
456 006
;
proc sql;
select distinct mr_nbr, count(id) as how_many
from have
group by mr_nbr
;
quit;
Is there a better way to know the percent of mr_nbr that have more than one id?in this case out three mr_nbr 2 have more than one id. which is 66.6%
Do you seek two answers?
Adapt it to create a summary table that can be analysed with proc freq which provides those cumulative percentages more conveniently than tabulate
proc sql;
CREATE TABLE summary1 AS
select mr_nbr, count(id) as how_many
from have
group by mr_nbr
;
quit ;
* generate cumulative frequency report ;
Proc freq data= summary1 ;
Table how_many ;
run ;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.