As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.
Here are some tips for How to share your SAS knowledge with your professional network.
Solutions in the Round -- Do You Believe In Magic? Turning Characters into Numbers and Back Again
From the WUSS abstract for this topic
It happens all the time--you have a number that you need in character format or a character string that you need in numeric format. Come PUT your ideas, and lend your INPUT (And other means) to the discussion on managing the conversions. Solutions in the Round (SITR) is a roundtable format section where attendees discuss approaches and solutions to a programming problem or SAS topic. Users from different perspectives and all experience levels are encouraged to participate.
Discussion at WUSS
Facilitator: Frank Ferriola
- Char to Num
- Num to Char
Char to Num: What ways can we use SAS?
- input( varname, format );
- proc format;
-- store as numeric, display as char -- use case: Wind directions --- convert headings to 16 cardinal dirs + calm, variable
- to_number (SQL)
- field has mostly numeric, some characters
-- read field as character, test numeric or letters --- if numeric, then convert it --- if NOT, then add handle exception(s )
Num to Char: What ways can we use SAS?
- put ( varname, format );
- proc format;
- to_char (SQL)
PROC SQL; select to_char(varname,fmt) into macrovar from datasetname
- call symput
- byte size
- str length
Further Discussion -- Open to All
Please join the conversation! Also, if you were one of the live participants, please feel free to correct any mistakes or omissions from our original discussion.