BookmarkSubscribeRSS Feed
eduar78
Calcite | Level 5
What is the following section accomplishing? */
productSales = INPUT(TRIM(sales), COMMA20.);
SELECT (product);
   WHEN (1)                   productName='Breakfast bar';
   WHEN (2)                   productName='Cookie bar';
   WHEN (3)                   productName='Savory meal bar';
OTHERWISE                     productName=.;
END;
RUN;

What is the following section accomplishing? 

1 REPLY 1
Kurt_Bremser
Super User

First, it converts a numerical value stored in a character variable into a numeric variable. Next, it creates a long-text character variable from codes in a numeric variable. The "otherwise" branch causes a NOTE concerning a numeric-to-character conversion, because of sloppy coding. The second action is better done with a custom format.

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore Now →
Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

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
  • 987 views
  • 1 like
  • 2 in conversation