Skip to content

Instantly share code, notes, and snippets.

@statgeek
Last active July 2, 2019 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save statgeek/3ba681b2fab3fb826ece2bfef14daf56 to your computer and use it in GitHub Desktop.
Save statgeek/3ba681b2fab3fb826ece2bfef14daf56 to your computer and use it in GitHub Desktop.
SAS - Example of how a format works
/*This program demonstrates how a built in SAS format works.
It uses the WORDS format to display the age as thirteen rather than 13.
It also creates two additional variables, one is numeric and formatted,
the second is a character variable with the same value
Author: F.Khurshed
Date: 2018-03-23
*/
*Create a sample data set;
data class;
set sashelp.class;
*create a variable identical to age, but formatted;
age_numeric_format = age;
format age_numeric_format words.;
*Recode variable into character rather than use a format;
age_character = put(age, words.);
run;
title 'Demo of Formats';
proc print data=class;
run;
title 'Check formats and type for AGE variables';
proc contents data=class;run;
title;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment