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
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.
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.
yes, we've a source columns as follows. Could you please tell me what that case when statement will do?
'6131300'n
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.
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.
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.