Character vs. Numeric

0

Contributed by Christine Kjellberg, Marketing Specialist and Joel Wilson, Systems Administrator

As Stacey and I have mentioned in previous posts, we have expanded our study group to include another co-worker, Joel Wilson. The three of us meet weekly to review and discuss all things certification-related. Today’s installment of Open Mic PROC Certify is authored by Joel, who will be taking the exam with Stacey and I next month.

Our Certification study group recently encountered a sample question which asked us to identify possible variable types: A) character only, B) Numeric only or C) Character or Numeric.

The following variables were presented as matches for A, B or C: 889003, S, Big Guy Men’s T-Shirt, 66E01, -53West, -7, 80.42317

We correctly answered the question by identifying the character-only variables such as “Big Guy’s Men’s T-Shirt” and by acknowledging that variables such as 66E01 could be either character or numeric. However, this did bring to mind the question, “Are there any variables that could NEVER be character?”

The answer is a bit more complicated than “yes” or “no”. On the surface, it appears that any variable could be character, but it depends on if the variable is existing or if it is yet-to-be-created by importing raw data. Any pre-existing variables in the form of dates, times and datetime literals are stored as integers and can NOT be converted to character using the PUT function.

In summary, all variables can be stored as character in SAS unless they are already formatted as dates, times or datetime literals, but it is also important to note that anything can be designated as character when importing raw data.

Share

About Author

Christine Kjellberg

Sr Associate Development Tester

Comments are closed.

Back to Top