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.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!

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