The values cannot be converted to numeric values. When SAS tries to automatically convert the values of PayRate to numeric values, the dollar sign blocks the process. Question: What would be the result if all the arguments in SUM function are missing? Answer: a missing value Question: What would be the denominator value used by the mean function if two out of seven arguments are missing? Answer: five Question: Give an example where SAS fails to convert character value to numeric value automatically? Answer: Suppose value of a variable PayRate begins with a dollar sign ($). 35 4 2 run data mydata2 set mydata a=sum(x,y,z) p=x+y+z run In the output, value of p is missing for 3rd, 4th and 5th observation as : ap 39 39 31 31 31 31 5. Example: data mydata input x y z cards 33 3 3 24 3 4 24 3 4. Question: Differnce b/w sum function and using ―+‖ operator? Answer: SUM function returns the sum of non-missing arguments whereas ―+‖ operator returns a missing value if any of the arguments are missing. Proc sort by month run proc means by month var avgtemp run Proc means is used to calculate average temperature by month (taking one variable value across an observation). For example: data average set temp avgtemp = mean( of T1 – T24 ) run Here arguments of mean function are taken across an observation. Question: What is the difference between SAS function and procedures? Answer: Functions expects argument value to be supplied across an observation in a SAS data set and procedure expects one variable value per observation. Question : What is the difference between reading the data from external file and reading the data from existing data set? Answer: The main difference is that while reading an existing data set with the SET statement, SAS retains the values of the variables from one observation to the next. For example: data work.calculus set p end=last If last run Where Calculus is a new data set to be created and Comp is the existing data set last is the temporary variable (initialized to 0) which is set to 1 when the set statement reads the last observation.
Question: Given an unsorted dataset, how to read the last observation to a new data set? Answer: using end= data set option. Whereas If want to process certain variables and do not want them to appear in the new data set, then specify drop= data set option in the data statement. Question : What is the difference between using drop= data set option in data statement and set statement? Answer: If you don‘t want to process certain variables and you do not want them to appear in the new data set, then specify drop= data set option in the set statement.
Question: What is the function of Stop statement? Answer: Stop statement causes SAS to stop processing the current data step immediately and resume processing statement after the end of current data step. Placing an explicit OUTPUT statement in a DATA step overrides the automatic output, so that observations are added to a data set only when the explicit OUTPUT statement is executed. Question: What is the function of output statement? Answer: To override the default way in which the DATA step writes observations to output, you can use anOUTPUT statement in the DATA step.