Hello, I am a SAS novice and learning SAS on my own. Here is what I'm trying to do: I have a data file, book.txt (attached), that records customer purchases at Amazon and Barnes&Nobel, along with some customer demographic variables. I want to write a program that reads the data in books.txt and generates a count dataset, that is, for each customer, counts the number of books purchased from Barnes&Noble. I want to keep the demographic variables, and then print the first 10 records of this new dataset. Afterwards, I want to ignore the demographic variables, so I'm only left with the top 10 customers that bought the most book, and the number of books they purchased from Barnes&Nobel. For reference, I'm using the University Edition on a Mac at the time. However, I do have the following code that was written for Windows (don't know which SAS edition) that I've been trying to modify to use in the University Edition, but I keep getting errors. -------------------- libname ABC 'C:\ABC'; proc import datafile="C:\ABC\books.txt" out=mydata1 dbms=tab replace; getnames=yes; run; proc import datafile="C:\ABC\books.txt" out=mydata1 dbms=dlm replace; delimiter='09'x; getnames=yes; run; proc sort data=Mydata; by domain; run; PROC SQL; CREATE TABLE BNN AS SELECT t1.userid, t1.education, t1.region, t1.hhsz, t1.age, t1.income, t1.child, t1.race, t1.country, t1.domain, t1.date, t1.product, t1.qty, t1.price FROM ABC.mydata t1 WHERE t1.domain CONTAINS 'barnes'; QUIT; proc sort data=abc.barnes; by userid; run; data count; set abc.barnes; by userid; cnt+1; if first.userid then cnt=1; run; proc print data=count (obs=10); title 'Top 10 Observations of Customers with Most Purchases from B&N'; run; proc sort data=Mydata; by domain; run; PROC SQL; SELECT Domain, COUNT(userid) FROM Mydata GROUP BY domain ORDER BY domain; QUIT;
... View more