BookmarkSubscribeRSS Feed

How to download your Netflix history and import to SAS

Started ‎03-10-2021 by
Modified ‎04-08-2021 by
Views 21,487

Recent blog posts and newsletter articles showed off how I used SAS to analyze my Netflix history. This sparked curiosity among several readers who wanted to do something similar with their own data. In this article, I'll show how to download and read this data into SAS.


Your Netflix viewing history is available from your Netflix account and profile settings.  Every so often the interface changes, so this may move around over time.  At the time of this writing I find my viewing history here, under the "Profile and Parental Controls" section:




Clicking View will lead you to a list of your most recent activity.  But the magic button is the Download all option on the bottom right of the page:




This will download a "NetflixViewingHistory.csv" file via your browser, with all of your streaming activity recorded since you established your account.  The CSV has a simple format: one record per streamed title, with two fields.




You might have multiple profiles associated with your account, used by different family members to control preferences, lists, favorites, etc.  If that's the case, you must repeat this download process for each profile in your account to gather a full view.  In my case, we have 5 different profiles in our account.  I named each CSV file with the associated profile name as I downloaded them.


NOTE: You do not have to trigger the "Download your personal information" option that Netflix provides. That produces more data than I've captured here -- but it takes Netflix a day or longer to fulfil the request.  Using the method I've shown above, you have instant access to simplified data for your viewing activity.

Oh, you don't have Netflix viewing data? Use mine.

No Netflix account? Too embarrassed by your viewing habits to analyze it yourself? I volunteer my data as tribute.  Here's a SAS program that fetches it from GitHub and imports the basics into SAS. (This program uses GIT* functions that require SAS 9.4 Maint 6 or SAS Viya 3.5 or later. It should work in SAS University Edition or SAS OnDemand for Academics.)


/* Utility macro to check if folder is empty before Git clone */ 
%macro FolderIsEmpty(folder);
  %local memcount;
  %let memcount = 0;
	%let filrf=mydir;
	%let rc=%sysfunc(filename(filrf, "&folder."));
  %if &rc. = 0 %then %do;
  	%let did=%sysfunc(dopen(&filrf));
  	%let memcount=%sysfunc(dnum(&did));
  	%let rc=%sysfunc(dclose(&did));
    %let rc=%sysfunc(filename(filrf));
  /* Value to return: 1 if empty, else 0 */
  %sysevalf(&memcount. eq 0)

options dlcreatedir;
%let repopath=%sysfunc(getoption(WORK))/sas-netflix-git;
libname repo "&repopath.";
data _null_;
 if (%FolderIsEmpty(&repoPath.)) then do;
    	rc = gitfn_clone( 
    	put 'Git repo cloned ' rc=; 
    else put "Skipped Git clone, folder not empty";

filename viewing "&repopath./NetflixData/*.csv";
data viewing (keep=title date profile);
 length title $ 300 date 8 
        profile $ 40 in $ 250;
 format date date9.;
 infile viewing dlm=',' dsd filename=in firstobs=2;
 input title date:??anydtdte.;
 if date^=. and title ^="";


If you want to take it a step further and parse the Netflix titles, you can create some "feature" variables as you read in the data:


data viewing;
 length title $ 300 date 8 
        maintitle $ 60 episode $ 40 season $ 12 
        profile $ 40 in $ 250;
 informat date mmddyy.;
 format date date9.;
 infile viewing dlm=',' dsd filename=in firstobs=2;
 input title date;
 array part $ 60 part1-part4;
 do i = 1 to 4;
	part{i} = scan(title, i, ':',);
  if (find(part{i},"Season")>0)
   then do;
 drop i;
 maintitle = part{1};
 episode = part{3};
 if Title ^= "Title";


 Example output:



If you want to start from just my data files yourself, you can find those in this GitHub folder.

Version history
Last update:
‎04-08-2021 11:13 AM
Updated by:



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Labels
Article Tags