The codes as follows are from a text book: DATA flowersales;
INFILE '*****\MyRawData\TropicalFlowers.dat' ;
INPUT CustomerID $4. @6 SaleDate MMDDYY10. @ 17 Variety $9. SaleQuantity SaleAmount;
* Sorting the data by saleamount in descending order;
PROC SORT DATA = flowersales;
BY DESCENDING SaleAmount;
RUN;
* Find biggest order and pass the customer id to a macro variable ;
DATA _NULL_ ;
SET flowersales;
IF _N_ = 1 THEN CALL SYMPUT( "selectedcustomer",CustomerID);
ELSE STOP ;
RUN;
PROC PRINT DATA = flowersales;
WHERE CustomerID = "&selectedcustomer" ;
FORMAT SaleDate WORDDATE18. SaleAmount DOLLAR7.;
TITLE "Customer &selectedcustomer Had the Single Largest Order" ;
RUN Since I want to see the purpose of IF _N_ =1 THEN.. , IF _N_ = 1 THEN CALL SYMPUT( "selectedcustomer",CustomerID); I change the above syntaxas as IF _N_ = 2 THEN CALL SYMPUT( "selectedcustomer",CustomerID); or IF _N_ = 9 THEN CALL SYMPUT( "selectedcustomer",CustomerID); or directly delte IF _N_ = THEN CALL SYMPUT( "selectedcustomer",CustomerID); The above four situations produce the same result (see attachment, for the dataset, please also see attachment), so it seems that IF _N_ = 1 is not necessary. Could anyone tell me is that true? If not, what is the actuall purpose of IF _N_ = 1 in this situation?
... View more