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.

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!

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.

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
  • 2 replies
  • 580 views
  • 0 likes
  • 2 in conversation