<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Output Sets When can you use them? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Output-Sets-When-can-you-use-them/m-p/456991#M115830</link>
    <description>&lt;P&gt;I know we can output multiple sets in one data statement, but I prefer this way (I think it is clearer):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Data Review.Subset_A ; 
	Set Learn.Blood ; 
	Combined = (.001*WBC + RBC) ; 
	Where Gender = 'Female' AND BloodType = 'AB' ; 
run ;&lt;/PRE&gt;
&lt;PRE&gt;Data Review.Subset_B ; 
	Set Learn.Blood ; 
	Combined = (.001*WBC + RBC) ; 
	If Gender = 'Female' AND BloodType = 'AB' AND Combined ge 14 ; 
run ; &lt;/PRE&gt;
&lt;PRE&gt;Proc Print data=Subset_A noobs ; run ; Proc Print data=Subset_B noobs ; run ;&lt;/PRE&gt;</description>
    <pubDate>Tue, 24 Apr 2018 17:56:59 GMT</pubDate>
    <dc:creator>tomrvincent</dc:creator>
    <dc:date>2018-04-24T17:56:59Z</dc:date>
    <item>
      <title>Output Sets When can you use them?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-Sets-When-can-you-use-them/m-p/456982#M115827</link>
      <description>&lt;P&gt;What if you want to create several output sets from an original set? Proc means has the output out= option. So, I figured I would try the code below, as it should intuitively work. But, no dice. Why not, when can I use the output statement, and how could II, in this case, generate two data sets from the set learn.blood without creating separate data steps (i.e data subset_A ahd data subset_B)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Libname Review'/folders/myfolders/Review' ;
Libname Learn'/folders/myfolders/Learn' ;  
Libname myformat'/folders/myfolders/sasuser.v94' ; 
Options fmtsearch=(myformat) ;

Data Review.Prob10_1 ; 
	Set Learn.Blood ; 
	Combined = (.001*WBC + RBC) ; 
	Where Gender = 'Female' AND BloodType = 'AB' ; 
		 Output Out = Subset_A ; 
	If Gender = 'Female' AND BloodType = 'AB' AND Combined ge 14 ; 
		 Output out = Subset_B ;
run ; 


Proc Print data=Subset_A noobs ; 
run ; 

Proc Print data=Subset_B noobs ; 
run ; &lt;/PRE&gt;&lt;P&gt;The Log is Below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 61         
 62         Libname Review'/folders/myfolders/Review' ;
 NOTE: Libref REVIEW was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /folders/myfolders/Review
 63         Libname Learn'/folders/myfolders/Learn' ;
 NOTE: Libref LEARN refers to the same physical library as LEARN2.
 NOTE: Libref LEARN was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /folders/myfolders/Learn
 64         Libname myformat'/folders/myfolders/sasuser.v94' ;
 NOTE: Libref MYFORMAT refers to the same physical library as SASUSER.
 NOTE: Libref MYFORMAT was successfully assigned as follows: 
       Engine:        V9 
       Physical Name: /folders/myfolders/sasuser.v94
 65         Options fmtsearch=(myformat) ;
 66         
 67         Data Review.Prob10_1 ;
 68         Set Learn.Blood ;
 69         Combined = (.001*WBC + RBC) ;
 70         Where Gender = 'Female' AND BloodType = 'AB' ;
 71          Output Out = Subset_A ;
                          _
                          79
                      ___
                      455
 ERROR 79-322: Expecting a RC.
 
 ERROR 455-185: Data set was not specified on the DATA statement.
 
 72         If Gender = 'Female' AND BloodType = 'AB' AND Combined ge 14 ;
 73          Output out = Subset_B ;
                          _
                          79
                      ___
                      455
 ERROR 79-322: Expecting a RC.
 
 ERROR 455-185: Data set was not specified on the DATA statement.
 
 74         run ;
 
 NOTE: The SAS System stopped processing this step because of errors.
 WARNING: The data set REVIEW.PROB10_1 may be incomplete.  When this step was stopped there were 0 observations and 8 variables.
 WARNING: Data set REVIEW.PROB10_1 was not replaced because this step was stopped.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 75         
 76         
 77         Proc Print data=Subset_A noobs ;
 ERROR: File WORK.SUBSET_A.DATA does not exist.
 78         run ;
 
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE PRINT used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 79         
 
 
 80         Proc Print data=Subset_B noobs ;
 ERROR: File WORK.SUBSET_B.DATA does not exist.
 81         run ;
 
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE PRINT used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 82         
 83         
 84         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 97         &lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Apr 2018 17:39:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-Sets-When-can-you-use-them/m-p/456982#M115827</guid>
      <dc:creator>ManitobaMoose</dc:creator>
      <dc:date>2018-04-24T17:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: Output Sets When can you use them?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-Sets-When-can-you-use-them/m-p/456991#M115830</link>
      <description>&lt;P&gt;I know we can output multiple sets in one data statement, but I prefer this way (I think it is clearer):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Data Review.Subset_A ; 
	Set Learn.Blood ; 
	Combined = (.001*WBC + RBC) ; 
	Where Gender = 'Female' AND BloodType = 'AB' ; 
run ;&lt;/PRE&gt;
&lt;PRE&gt;Data Review.Subset_B ; 
	Set Learn.Blood ; 
	Combined = (.001*WBC + RBC) ; 
	If Gender = 'Female' AND BloodType = 'AB' AND Combined ge 14 ; 
run ; &lt;/PRE&gt;
&lt;PRE&gt;Proc Print data=Subset_A noobs ; run ; Proc Print data=Subset_B noobs ; run ;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Apr 2018 17:56:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-Sets-When-can-you-use-them/m-p/456991#M115830</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2018-04-24T17:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: Output Sets When can you use them?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-Sets-When-can-you-use-them/m-p/456994#M115832</link>
      <description>&lt;P&gt;if you want it in one, here it is:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data Review.Subset_A Review.Subset_B ; &lt;BR /&gt;Set Learn.Blood ; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Combined = (.001*WBC + RBC) ; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if Gender = 'Female' AND BloodType = 'AB' then output Review.Subset_A;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;If Gender = 'Female' AND BloodType = 'AB' AND Combined ge 14&amp;nbsp; then output Review.Subset_B;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 18:02:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-Sets-When-can-you-use-them/m-p/456994#M115832</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2018-04-24T18:02:23Z</dc:date>
    </item>
    <item>
      <title>Re: Output Sets When can you use them?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-Sets-When-can-you-use-them/m-p/456996#M115833</link>
      <description>&lt;P&gt;Thanks for looking at this. I am aware of the method you have shown. I guess, at the core, I am trying to understand why the output statements are not generating data sets the way I have written them. When do output statements generate data sets, and when do they not? This is about understanding SAS more than about this specific example.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 18:04:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-Sets-When-can-you-use-them/m-p/456996#M115833</guid>
      <dc:creator>ManitobaMoose</dc:creator>
      <dc:date>2018-04-24T18:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: Output Sets When can you use them?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-Sets-When-can-you-use-them/m-p/457002#M115835</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/158207"&gt;@ManitobaMoose&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for looking at this. I am aware of the method you have shown. I guess, at the core, I am trying to understand &lt;FONT size="4"&gt;&lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;why the output statements are not generating data sets the way I have written them&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;. When do output statements generate data sets, and when do they not? This is about understanding SAS more than about this specific example.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Simple: Your syntax is incorrect for what you attempt/want to do.&lt;/P&gt;
&lt;P&gt;Just like in any programming language I have to follow the syntax rules to do anything with code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your attempt to send output to data set without telling SAS that a dataset of that name is expected to be created is somewhat analogous to doing arithmetic with variables that have not been assigned a value or type. SAS will allow that though usually with a note in the log about variable x has not been initialized. Some program languages would consider that a critical fault and halt as you need to tell the program what type of variable it is before any use.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 18:14:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-Sets-When-can-you-use-them/m-p/457002#M115835</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-04-24T18:14:52Z</dc:date>
    </item>
    <item>
      <title>Re: Output Sets When can you use them?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-Sets-When-can-you-use-them/m-p/457015#M115841</link>
      <description>&lt;P&gt;I think the point you are missing is that the OUTPUT statement in PROC MEANS (or any procedure) is a different statement than the OUTPUT statement in a DATA step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The DATA step is really its own language.&amp;nbsp; PROCs are really their own things as well.&amp;nbsp; There are some statements, like WHERE which do the same thing in a DATA step and a PROC step.&amp;nbsp; But there are many statements which can only be used in the DATA step.&amp;nbsp; And some statements, like OUTPUT, are named the same but do different things in the DATA step and PROC step, and have different syntax.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The OUTPUT statement of PROC MEANS uses syntax like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=sashelp.class ;
  output out=want ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The OUTPUT statement of the DATA step uses syntax like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set sashelp.class ;
  output want ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;They are two different statements, which happen to have the same name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you tried 'output want;' in PROC MEANS, it will be a syntax error.&amp;nbsp; If you tried 'output out=want;' in the DATA step, it's a syntax error.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 19:11:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-Sets-When-can-you-use-them/m-p/457015#M115841</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2018-04-24T19:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: Output Sets When can you use them?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-Sets-When-can-you-use-them/m-p/457023#M115842</link>
      <description>&lt;P&gt;Because your data statement didn't refer to the 2 output datasets you wanted.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 18:49:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-Sets-When-can-you-use-them/m-p/457023#M115842</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2018-04-24T18:49:08Z</dc:date>
    </item>
  </channel>
</rss>

