BookmarkSubscribeRSS Feed
ren2010
Obsidian | Level 7
Hi,

I have a situation like the following

example:

doctor
-----------------------------------
specialtykey doctorname
1 john
2 Sam
3 Mary



doctor specialty table
----------------------------
specialtykey specialty
1 ENT
1 Cardiologist
1 General
2 eyes
2 family
3 Gastro

My output dataset should look like this

Final
----------
doctorname specialty1 specialty2 specialty3
john ENT Cardiologist General
sam eyes family
mary Gastro



Please help
2 REPLIES 2
Patrick
Opal | Level 21
Hope this was for a 'real' situation and not only to do someones homework...
HTH
Patrick

data doctor;
input specialtykey doctorname $30.;
datalines;
1 john
2 Sam
3 Mary
;
run;

data specialty;
input specialtykey specialty $30.;
datalines;
1 ENT
1 Cardiologist
1 General
2 eyes
2 family
3 Gastro
;
run;

proc sql;
create view DoctorSpecialty as
select d.*,s.specialty
from doctor as d left join specialty as s
on d.specialtykey=s.specialtykey
order by doctorname
;
quit;

proc transpose data=DoctorSpecialty out=want(drop=_name_) prefix=Specialty;
by doctorname;
var specialty;
run; Looking at the two tables the data model looks kind of weird to me. I would expect the key to be "doctorkey" and this key to be the foreign key in specialty.

If this would be normalised then I would expect to see the following tables:
Doctor {doctorkey, name}
Specialty {specialtykey,specialty}
DoctorSpecialty {doctorkey,specialtykey}
ren2010
Obsidian | Level 7
Thanks So Much.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1189 views
  • 0 likes
  • 2 in conversation