2

I am trying to find a list of all US universities and colleges for my Ph.D. project. I have downloaded the scorecard data; however, it is missing major universities, like Brown, the Univeristy of California, and the Univeristy of Texas... and many more.

Any help would be appreciated.

1

1 Answer 1

0

I believe almost all universities and colleges are in Wikidata, so you can query it:

SELECT DISTINCT ?item ?itemLabel 
WHERE 
{
  {
    ?item p:P31/ps:P31/wdt:P279* wd:Q3918. # University or subclass
  }
  UNION {
    ?item p:P31/ps:P31/wdt:P279* wd:Q189004. # College or subclass
  }
  ?item wdt:P17 wd:Q30. # USA

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

https://w.wiki/7JP$

This currently gets me 4319 results in 8 seconds.

There may be duplicates or near-duplicates, for instance a university that contains a college or other special cases.

5
  • Thank you very much. Would it be possible to get a list of whether they are public or private? or maybe the town they are located in? Aug 24, 2023 at 9:10
  • @AlanoudNaif: Yes, you can probably add optional properties for the city, and get the name of the class for public/private. See the usage of OPTIONAL {?QID wdt:P131 ?cityQID. ?cityQID rdfs:label ?city. FILTER (lang(?city) = "en").} and ?QID p:P31/ps:P31 ?typeQID. ?typeQID wdt:P279* wd:Q3918. ?typeQID rdfs:label ?type. FILTER (lang(?type) = "en"). at github.com/database-of-embassies/database-of-embassies/blob/… for inspiration.
    – Nicolas Raoul
    Aug 24, 2023 at 10:22
  • When I run it, it gives me the following error message: Query is malformed: Encountered " "optional" "OPTIONAL "" at line 14, column 1. Aug 24, 2023 at 10:38
  • this is the code I inserted: SELECT DISTINCT ?item ?itemLabel WHERE { { ?item p:P31/ps:P31/wdt:P279* wd:Q3918. # University or subclass } UNION { ?item p:P31/ps:P31/wdt:P279* wd:Q189004. # College or subclass } ?item wdt:P17 wd:Q30. # USA SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } OPTIONAL {?QID wdt:P131 ?cityQID. ?cityQID rdfs:label ?city. FILTER (lang(?city) = "en"). ?QID p:P31/ps:P31 ?typeQID. ?typeQID wdt:P279* wd:Q3918. ?typeQID rdfs:label ?type. FILTER (lang(?type) = "en").} Aug 24, 2023 at 12:10
  • You may want to ask at wikidata.org/wiki/Wikidata:Request_a_query Please say exactly what you want to achieve, and post your current full query, even if it does not work.
    – Nicolas Raoul
    Aug 25, 2023 at 1:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.