* Kids5 Example Perform several database using base SAS; option nodate ls=80 pageno=1; data kids; infile "c:/datasets/kids.txt" firstobs=2; length name $ 15; input name $ gender $ age; * Display beginning of kids dataset; proc print data=kids (obs=20); proc print data=kids; title "Show girls only"; var name age; where gender="F"; proc means data=kids mean; title "Compute mean age by gender"; class gender; * Assign Doctors randomly to patients; data kids2; set kids; rannum = rand("table", 1/5, 1/5, 1/5, 1/5, 1/5); select(rannum); when (1) prof_id = 328; when (2) prof_id = 517; when (3) prof_id = 694; when (4) prof_id = 798; when (5) prof_id = 803; end; drop rannum; proc print data=kids2; data teachers; input prof_id teacher_name $ @@; datalines; 328 Rao 517 Zapata 694 Chen 798 Murphy 803 Nkosi ; proc print data=teachers; * Before merging datasets, both datasets must be sorted by merge variable; proc sort data=kids2; by prof_id; * In a SAS merge statement, the by variable must be the same in both input files; data kids3; title "Kids name with teachers name"; merge kids2 teachers; by prof_id; keep name teacher_name; proc sort data=kids3; by name; proc print data=kids3; run; quit;