99.0k views
3 votes
Which statement retains the value of Sales2Dte in the PDV across iterations of the DATA step?

a. Total_Retail_Price+Sales2Dte;
b. Sales2Dte+Total_Retail_Price;
c. Sales2Dte=Sales2Dte+Total_Retail_Price;

User Henry Le
by
7.7k points

1 Answer

4 votes

Final answer:

The correct statement is 'c. Sales2Dte=Sales2Dte+Total_Retail_Price;'. This explicit assignment statement using the '=' operator ensures that Sales2Dte retains its value and is updated with the value of Total_Retail_Price in each iteration of the DATA step.

Step-by-step explanation:

The correct statement to retain the value of Sales2Dte in the Program Data Vector (PDV) across iterations of the DATA step in a SAS program is c. Sales2Dte=Sales2Dte+Total_Retail_Price;

In option a (Total_Retail_Price+Sales2Dte;) and option b (Sales2Dte+Total_Retail_Price;), the use of the ‘+’ operator without any equal sign to the left of Sales2Dte represents a sum statement in SAS, not an assignment statement. The sum statement automatically retains the value of the variable on its left (Sales2Dte) across DATA step iterations. However, option c (Sales2Dte=Sales2Dte+Total_Retail_Price;) explicitly tells SAS to retain the current value of Sales2Dte, increase it by the value of Total_Retail_Price, and bring the resulting value to the next iteration of the DATA step. The equal sign is crucial since it dictates that the result on the right should be stored back into the variable on the left, effectively updating its value while retaining it through the loop.

User Euvl
by
8.1k points