BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Babloo
Rhodochrosite | Level 12

Appreciate if some of you help me understand the meaning of the following case when statement.

 

case when upcase(DOMAIN)='NL' then '6131300'n 
     else '6231300'n 
end  as COMMISSION_AMT format=nlnum18.5
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Create a variable named COMMISSION_AMT whose value depends on the value of DOMAIN.  When DOMAIN has the value 'NL' then use the value from the '6131300'n variable otherwise use the value from the '6231300'n variable.  Attach the display FORMAT of NLNUM18.5 to the new variable.

View solution in original post

5 REPLIES 5
LinusH
Tourmaline | Level 20

You are not stating what it is you don't understand, but my guess the 

'6131300'n

stuff. It seem that you have source colunms with those names, hence the use of the n literal. Otherwise it would be interpreted as a string. 

Data never sleeps
Babloo
Rhodochrosite | Level 12

yes, we've a source columns as follows. Could you please tell me what that case when statement will do?

 

'6131300'n
Kurt_Bremser
Super User

It either assigns the value of '6131300'n or '6231300'n (you should really get rid of such extremely stupid variable names three days before yesterday) to the newly created variable, depending on the condition.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

The n after the string means the string is a named literal.  Named literals are used when dealing with poor data sources (such as Excell) where variable names are not compliant with SAS standards.  So in the case given variables cannot start with a number or special character, hence 6 is not a valid first character of a variable name.  To access these variables, the named literal is given and SAS internally converts this (or uses it) to access that data.

Whilst this is available and can be used to bring data into the SAS system, once it is in the SAS system it is highly recommended to give them SAS conformant variable names to remove this need for named literals. 

Tom
Super User Tom
Super User

Create a variable named COMMISSION_AMT whose value depends on the value of DOMAIN.  When DOMAIN has the value 'NL' then use the value from the '6131300'n variable otherwise use the value from the '6231300'n variable.  Attach the display FORMAT of NLNUM18.5 to the new variable.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 842 views
  • 4 likes
  • 5 in conversation