proc sql;
create table x2 as
(select student_school_id, student_grade
from jsu.tbl_student_roster
having student_grade="9");
run;
Using R
sqldf("
sELECT commonID
FROM time1data
GROUP BY commonID
;
")
sqldf("
SELECT datatype,
school,
count(DISTINCT commonID) AS n_school1
FROM time1data
GROUP BY school
UNION
SELECT datatype,
school,
count(DISTINCT commonID) AS n_school1
FROM time2data
GROUP BY school
ORDER BY n_school1 DESC;
" )
sqldf("
sELECT COUNT(*)
FROM time1data;
")
SELECT
region,
MAX(age) AS age_of_oldest_athlete
FROM athletes AS a
-- First JOIN statement
JOIN summer_games AS s
ON a.id = s.athlete_id
-- Second JOIN statement
JOIN countries AS c
ON s.country_id = c.id
GROUP BY region;
-- Query sport, events, and athletes from summer_games
SELECT
sport,
COUNT(DISTINCT event) AS events,
COUNT(DISTINCT athlete_id) AS athletes
FROM summer_games
GROUP BY sport;