全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
20568 29
2010-08-05
Example Here are the flower sales data consisting of customer ID, date of sale, variety of flower, and quantity.
240W 02-07-2008 Ginger 120
240W 02-07-2008 Protea 180
356W 02-08-2008 Heliconia 60
356W 02-08-2008 Anthurium 300
188R 02-11-2008 Ginger 24
188R 02-11-2008 Anthurium 24
240W 02-12-2008 Heliconia 48
240W 02-12-2008 Protea 48
356W 02-12-2008 Ginger 240
In this example, the grower wants a program that will find the customer with the single largest order, and print all the orders for that customer.
* Read the raw data;
DATA flowersales;
INFILE 'c:\MySASLib\TropicalSales.dat';
INPUT CustomerID $4. @6 SaleDate MMDDYY10. @17 Variety $9. Quantity;
PROC SORT DATA = flowersales;
BY DESCENDING Quantity;
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.;
TITLE "Customer &selectedcustomer Had the Single Largest Order";
RUN;

请问各位高手,IF _N_ = 1 是什么意思?
网上查到是:An internal SAS counter in the data step which contains the current iteration number of the data step.
能不能具体点?好像还没理解
谢谢大虾
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2010-8-5 10:14:19
_n_是SAS系统变量,是在运行过程中产生的变量,作用就是记录当前是第几条record在运行
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-8-5 10:16:27
the first observation in the dataset.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-8-5 10:20:01
与STATA中的_n,_N类似
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-8-5 10:32:38
_n_=1就是第一行。。。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-8-5 10:42:11
data步的循环次数
某种意义上是第几条记录......
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群