如何在SAS中组合多个数据集命令,就像我们在SQL中通过UNION组合不同的查询一样

如何在SAS中组合多个数据集命令,就像我们在SQL中通过UNION组合不同的查询一样,sas,enterprise-guide,Sas,Enterprise Guide,我的问题是如何在SAS中组合多个数据集命令,就像我们在SQL中通过UNION组合不同的查询一样 我必须使用a条件在工作库中创建两个数据集 data new_car_sales2; set mylib1.car_sales; where (15<price_in_thousands <20) and price_in_thousands NE .; run; data new_car_sales3; set mylib1.car_sale

我的问题是如何在SAS中组合多个数据集命令,就像我们在SQL中通过UNION组合不同的查询一样

我必须使用a条件在工作库中创建两个数据集

    data new_car_sales2;
    set mylib1.car_sales;
    where (15<price_in_thousands <20) and price_in_thousands NE .;
    run;
    data new_car_sales3;
    set mylib1.car_sales;
    where (20<price_in_thousands <25) and price_in_thousands NE .;
    run;
数据新车销售2;
设置mylib1.car\u销售;

where(15您可以将它们放在同一个SET语句中,并将
where
放在
SET
语句中

  data new_car_sales2;
    set mylib1.car_sales(where=( (15<price_in_thousands <20) and price_in_thousands NE .)) 
        mylib1.car_sales(where=((20<price_in_thousands <25) and price_in_thousands NE .);
  run;
data new_car_sales2 new_car_sales3;
  set mylib1.car_sales;
  if (15<price_in_thousands <20) then output new_car_sales2;
  if (20<price_in_thousands <25) then output new_car_sales3;
run;
数据新车销售2;

设置mylib1.car_sales(其中=((15您的问题令人困惑,因为代码示例是从一个输入创建多个输出数据集,但在本文中,您讨论了用于从多个输入数据集创建单个输出数据集的SQL UNION

可以在DATA语句上引用多个输出数据集,然后指定要在output语句上写入的数据集

  data new_car_sales2;
    set mylib1.car_sales(where=( (15<price_in_thousands <20) and price_in_thousands NE .)) 
        mylib1.car_sales(where=((20<price_in_thousands <25) and price_in_thousands NE .);
  run;
data new_car_sales2 new_car_sales3;
  set mylib1.car_sales;
  if (15<price_in_thousands <20) then output new_car_sales2;
  if (20<price_in_thousands <25) then output new_car_sales3;
run;

您希望在输出中包含一个或两个数据集吗?这正如我所期望的和我所寻找的一样。只使用数据集和集一次,并在同一个库中创建多个数据集。谢谢!!@user2827927如果您想要Tom在此处显示的内容,您要求完全反向使用。
UNION
组合两个数据集。上面拆分了一个数据集请将问题一分为二。请编辑您的问题以反映您的实际需求。注意:这回答了问题似乎要问的问题(如何在SAS中执行与
UNION
相同的操作),但注释似乎表明它没有回答原始海报想要问的问题(反之,如何在一个数据步骤中创建多个表)。如果问题已更新,我将删除此项。