Question-116: What is an alternate way to remove duplicate data?

Answer: You can use the FIRST and LAST expressions to remove the duplicate data. Variable created when sorting containing Boolean for each BY variable.

  • 1: It means current observation is either ‘FIRST/LAST’ in the By group.
  • 0: It means current observation is not either ‘FIRST/LAST’ in the By group.

 

Question-117: If you want to remove the duplicate observations based on the few fields like out of 10 fields if you want to remove duplicated based on 3 fields. How can you achieve that?

Answer: Then you would be using the NONDUPKEY option and in the BY statement you would be using 3 variables based on which you want to remove the duplicate values.

 

Question-118: How would you find all the numeric and character variables in the current dataset?

Answer: You can use _NUMERIC_, _CHARACTER_ and _ALL_ automatic variables where _ALL_ represent all the defined variable, _NUMERIC_ gives list of all the numeric variable and similarly _CHARACTER_ gives all the character variable list.

 

Question-119: What is the difference between SELECT and IF-THEN-ELSE statement?

Answer: As such there is no difference you can use both to generate the same output but you should prefer SELECT statement when you have series of conditions and all are independent because SELECT-WHEN is more CPU efficient compare to IF-THEN-ELSE statement.

 

Question-120: How can I convert a Numeric variable in a Character variable?

Answer: You can use the PUT() function to convert a numeric value to a character variable. As example you can see

PUT(1000, 5) would generate ‘  1000’