One side effect of the global pandemic which has afflicted the world over the past few years has been the clamp-down on international travel. Like many people I haven’t been abroad for about two years now and I’ve missed it. One thing I always enjoyed about my annual visits to the USA for SAS Global Forum has been the chance to visit US cities which are a little bit out of the normal UK tourist route and especially to sample the wide variety of street food on offer. Here in the UK street food is pretty much limited to burgers and hot dogs whereas there always seems to be so much more variety in the US.
In this edition of Free Data Friday we will be looking at data relating to mobile food permits granted in the city of San Francisco to see if we can determine what are the most common foods you can buy from food trucks and carts in that beautiful city.
The data can be downloaded from the city of San Francisco data site as a CSV file.
I imported the file using PROC Import setting guessingrows to 500 (there are just under 500 records in the file) to reduce the chance of import errors.
filename reffile '/home/chris52brooks/SFFood/Mobile_Food_Facility_Permit.csv';
proc import datafile=reffile
dbms=csv
out=sfimport
replace;
getnames=yes;
guessingrows=500;
run;
This gives me a file containing a variable called FoodItems looking like this:
As shown above the permits include details of the specific food types to be sold which we can use to discover the items most likely to be sold from these trucks or carts. The field consists of what appears to be multiple free text items colon delimited. In order to analyse this, we will have to split each record up into one record per food item. There is also the issue of synonyms to be considered (e.g., I consider burgers, hamburgers and cheeseburgers to be essentially the same item). In the following data step I looped through the field utilising the scan function to read and output each food type to a new data set. Also, I standardise the different burger types and drop records for “Cold Truck” which is not a food type.
data foodtypes;
length foodtype $50;
set sfimport(where=(status="APPROVED") keep=applicant status fooditems);
do i=1 to countw(fooditems,":");
foodtype=scan(fooditems,i,":");
foodtype=propcase(trim(foodtype));
if find(foodtype,"Cheeseburgers") or find(foodtype,"Hamburger") then do;
foodtype="Burgers";
end;
if foodtype ne "Cold Truck" then
output;
end;
run;
This process isn’t perfect and we could undoubtedly do a better job with Sas Visual Text Analytics if that were available in Sas OnDemand for Academics, but we’re not aiming for pinpoint accuracy here and so I believe this is a reasonable approach (feel free to disagree…).
Next, I used PROC SQL to create a summary file of the count of each food type and used Proc SGPlot to create a bar chart of the top five food items.
proc sql;
create table ftypesummary as
select distinct foodtype,
count(foodtype) as num
from foodtypes
group by foodtype
order by num desc;
quit;
ods graphics / reset;
proc sgplot data=ftypesummary(obs=5);
title1 "San Francisco Mobile Food Permits";
title2 "Top 5 Food Types Licenced";
footnote j=r "Data From: https://datasf.org/";
hbar foodtype / response=num
datalabel datalabelattrs=(weight=bold) categoryorder=respdesc;
xaxis grid label="Number of Approved Permits";
yaxis grid label="Food Type";
run;
Looking at the chart it showed burgers and hot dogs at the top of the list of items which was no surprise but in third place came burritos which I found interesting since in the UK you would be hard pressed to find a burrito outside a Mexican or Tex-Mex restaurant, much less a food van. It would be interesting to find data from other cities, perhaps from a different region of the US to see if this is a regional phenomenon or a more general US one.
Did you find something else interesting in this data? Share in the comments. I’m glad to answer any questions.
Hit the orange button below to see all the Free Data Friday articles.
It's fantastic to reminisce about exploring different cities and savoring the diverse street food offerings, especially when it's been a while since traveling. The variety of street food in the US, compared to the UK, is indeed remarkable—there's a world of flavors waiting to be discovered.
In this edition of Free Data Friday, let's delve into the data on mobile food permits in San Francisco. Exploring these permits might unveil the rich tapestry of culinary delights available from food trucks and carts in this beautiful city. It's a bit like seeking the best breakfast tacos in San Antonio—a quest to uncover the unique and diverse tastes that cities like San Francisco have to offer. Here's to exploring the colorful world of street food through data!
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.