/* Using SAS Formats to add "star ratings" to SAS report columns */ /* Example shared by Chris Hemedinger on SAS Dummy blog */ /* June 2014 */ data work.movies; attrib DVD_Title length=$48 label='DVD Title' ; attrib Rating length=8; INFILE DATALINES DSD; INPUT DVD_Title Rating ; DATALINES4; "Hairspray",5 "Return to Never Land",4 "The History Boys",4 "Bridge to Terabithia",4 "Oklahoma!",4 "Bee Movie",3 "Four Rooms",4 "Mad Men: Season 2: Disc 3",5 "Horton Hears a Who!",4 "Modern Family: Season 1: Disc 4",5 "The Queen",4 "South Pacific",3 "Waiting for Guffman",4 "Grindhouse: Death Proof",3 "Burn After Reading",4 "The Men Who Stare at Goats",5 "Up in the Air",4 "It's Complicated",4 "Doctor Who: The Beginning: Disc 1",4 "The Tiger and the Snow",4 "Rushmore",4 "The Color of Paradise",4 "Dark City: Director's Cut",3 "In the Loop",3 "The Spiderwick Chronicles",4 "Defying Gravity: Season 1: Disc 4",5 "The Mikado",2 "The Importance of Being Earnest",4 "Rocket Science",4 "Before the Devil Knows You're Dead",3 "Children of Heaven",4 "Charlotte's Web",5 "Indiana Jones/Kingdom of the Crystal Skull",4 "Babel",4 "Everything Is Illuminated",5 "The Curious Case of Benjamin Button",5 "The Madness of King George",5 "Sweeney Todd",4 "Ratatouille",5 "Mrs. Brown",4 "Casino Royale",3 "Best of Abbott & Costello: Vol. 3: Disc 4",5 "The Dark Knight",4 "Masterpiece Theatre: Wind in the Willows",4 "Jumper",2 "Corpse Bride",4 "Son of Rambow",4 "Iron Man",5 "Dreamgirls",5 "Barbie Fairytopia: Magic of the Rainbow",3 "Harry Potter and the Order of the Phoenix",4 "John Adams: Disc 3",5 "Spider-Man 3",4 "The Darjeeling Limited",5 "Stuart Little",4 "Michael Clayton",4 "Gilligan's Island: Season 1: Disc 1",4 "Superman II: The Richard Donner Cut",4 "Alvin and the Chipmunks",3 "Animaniacs: Vol. 1: Disc 1",3 "Old School",4 "The Departed",4 "Evan Almighty",5 "Pan's Labyrinth",4 "Idiocracy",3 "Knocked Up",4 "Flicka",3 "Curse of the Golden Flower",3 "Barbie Mermaidia",3 "The Bourne Ultimatum",4 "Meet the Robinsons",5 "Borat",4 "The Simpsons Movie",5 "The Last Mimzy",4 "The Invisible",4 "Volver",4 "Barbie as the Princess and the Pauper",3 "The Jungle Book",5 "This Film Is Not Yet Rated",4 "The Lake House",3 "Angels in the Outfield",3 "Flushed Away",5 "Bottle Rocket",5 "The Thin Man",4 "Best in Show",5 "Ella Enchanted",4 "Stranger than Fiction",4 "Robin Hood",4 "The Illusionist",4 "Superman Returns",4 "Thank You for Smoking",4 "Little Miss Sunshine",5 "Night at the Museum",5 "Ghost World",4 "Barbie in the 12 Dancing Princesses",3 "A Prairie Home Companion",4 "Thunderbirds",3 "Over the Hedge",4 "Trainspotting",3 "James and the Giant Peach",4 "Akeelah and the Bee",4 "The Triplets of Belleville",4 "American Splendor",4 "The Lion, the Witch & the Wardrobe",4 "The Three Burials of Melquiades Estrada",4 "Winter Passing",3 "X-Men 3: The Last Stand",4 "Memoirs of a Geisha",4 "Donnie Darko: Director's Cut",4 "Pride & Prejudice",4 "The 40-Year-Old Virgin",4 "Good Night, and Good Luck",4 "March of the Penguins",4 "The School of Rock",3 "The Kids in the Hall: Season 3: Disc 3",4 "Gangs of New York",4 "Home on the Range",3 "Troy",3 "Chicken Little",4 "Walk the Line",5 "Spanglish",2 "City of God",4 "Wedding Crashers",4 "King Kong",4 "Songcatcher",4 "Lemony Snicket: Unfortunate Events",4 "The Office Special",4 "The End of the Affair",4 "Lock, Stock and Two Smoking Barrels",4 "Robots",3 "Richard Jeni: A Big Steaming Pile of Me",4 "House of Flying Daggers",3 "Fantastic Four",4 "21 Grams",3 "Garden State",5 "I Heart Huckabees",4 "What the #$*! Do We Know!?",2 "Shaun of the Dead",4 "The Cooler",4 "Ray",4 "Hitch",4 "The Young Ones: Disc 1",5 "The Hitchhiker's Guide to the Galaxy",3 "High Fidelity",5 "Be Cool",2 "The Apple Dumpling Gang",4 "Seabiscuit",4 "Office Space",4 "The Aviator",4 "Sideways",5 "Because of Winn-Dixie",3 "Meet the Fockers",4 "The Jerk",4 "The Day After Tomorrow",3 "Million Dollar Baby",4 ;;;; RUN; /* ODS EXCAPECHAR needed to set style/unicode cues */ ods escapechar='~'; /* Captured these in macro variables for readability and */ /* easy maintenance */ %let graystar = ~{style [color=ygr] ~{unicode '2605'x}}; %let redstar = ~{style [color=red] ~{unicode '2605'x}}; proc format lib=work; value stars 1 = "&graystar.&graystar.&graystar.&graystar." 2 = "&redstar.&graystar.&graystar.&graystar." 3 = "&redstar.&redstar.&graystar.&graystar." 4 = "&redstar.&redstar.&redstar.&graystar." 5 = "&redstar.&redstar.&redstar.&redstar." ; title "Movie titles with STARS on THARS"; proc print data=work.movies noobs; format rating stars.; run;