SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
ChrisHemedinger
Community Manager

It's nearly July 17, also known as #WorldEmojiDay! In this challenge, the famous CLASS data set received an update for the modern times we live in. We still have student names, but all other attributes have been replaced with emojis. We've now got fields for gender (we don't use the term "sex" anymore), current mood, "spirit" animal, and appointment time.

 

Snippet of the new CLASSSnippet of the new CLASS

You'll find the new data set attached as a CSV file (modern_class.csv) to this message. Your job is to read the new class data into SAS and "translate" the emoji fields into words (presumably so that people who don't "speak emoji" can read it).  Create a SAS report (PROC PRINT is fine) that contains the "wordy" version of the data. Show your code and results in your replies.

 

Hints/Notes:

  • This blog post teaches you how to work with emojis in SAS, and provides sample code you can use to retrieve the definitions and codes for all emojis. The most robust solution will be able to process any emoji encountered in the data.
  • You will need to use a SAS session with UTF-8 encoding. If you use SAS OnDemand for Academics it's UTF-8 by default. And SAS Viya is always UTF-8. Emojis rely on Unicode, so limited encodings like wlatin1 will not be able to process these data.
  • Keep in mind that modern systems are not limited to "male" and "female" for gender, and neither is this updated CLASS data set.

(Note: last year we shared this challenge on SAS Analytics Explorers. Decided to share with a wider audience this time!)

Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!
1 REPLY 1
Patrick
Opal | Level 21

The clocks made that interesting. 

data appt_time;
  fmtname='$appt_time';
  do i=128336 to 128347;
    start=unicode(cats('&#',i,';'),'ncr');
    label=put(mod(i,128335)*3600,hhmm.);
    output;
  end;
  do i=128348 to 128359;
    start=unicode(cats('&#',i,';'),'ncr');
    label=put(mod(i,128347)*3600+1800,hhmm.);
    output;
  end;
run;
proc format lib=work cntlin=work.appt_time;
run;
proc format;
  value $gender
    👦='Male'
    👧='Female'
    🧒='Non-Binary'
    other='Undefined'
    ;
  /* and so on for the rest */
run;

data modern_class;
  infile datalines dlm=',' dsd truncover;
  input (name gender mood animal appt_time) ($);
datalines;
Alfred,👦,😏,🦄,🕛
Alice,👧,😒,🦓,🕧
Barbara,👧,🙄,🦌,🕐
Carol,🧒,😬,🦬,🕜
Henry,👦,🤥,🐮,🕑
James,👦,😌,🐂,🕝
Jane,👧,😔,🐃,🕒
Janet,🧒,😪,🐄,🕞
Jeffrey,👦,🤤,🐷,🕓
John,👦,😴,🐖,🕟
Joyce,👧,😒,🐗,🕔
Judy,🧒,🙄,🐽,🕠
Louise,👧,😬,🐏,🕕
Mary,👧,😌,🐑,🕡
Philip,👦,😔,🐐,🕖
Robert,🧒,😪,🐪,🕢
Ronald,👦,😏,🐫,🕗
Thomas,👦,😒,🦙,🕣
William,👦,🙄,🦒,🕘
;

proc print data=modern_class;
  format gender $gender. appt_time $appt_time.;
run;

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 518 views
  • 1 like
  • 2 in conversation