<?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 Several things regarding output and assigment statements in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Several-things-regarding-output-and-assigment-statements/m-p/456949#M115808</link>
    <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am reviewing SAS from the book Learning SAS by example. I am trying to use everything without looking in the book. However, on this problem, several issues came up.&lt;/P&gt;&lt;P&gt;1. Why can't I include the assignment statement 'combined'' from the Set learn.blood?&lt;/P&gt;&lt;P&gt;2. Why don't the output statement generate subset_A and subset_B as written in the code below? When I proc print subset_?A and subset_B SAS tells me that they do not exist. Thanks for your help.&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 = Sum(.001*WBC + RBC) ; 
	Where Gender = 'Female' AND BloodType = 'AB' ; 
		 Output = Subset_A ; 
	Where Gender = 'Female' AND BloodType = 'AB' AND Combined ge 14 ; 
		 Output = Subset_B ; 
run ; 


Proc Print data=Subset_A noobs ; 
run ; 

Proc Print data=Subset_B noobs ; 
run ; &lt;/PRE&gt;</description>
    <pubDate>Tue, 24 Apr 2018 16:41:02 GMT</pubDate>
    <dc:creator>ManitobaMoose</dc:creator>
    <dc:date>2018-04-24T16:41:02Z</dc:date>
    <item>
      <title>Several things regarding output and assigment statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Several-things-regarding-output-and-assigment-statements/m-p/456949#M115808</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am reviewing SAS from the book Learning SAS by example. I am trying to use everything without looking in the book. However, on this problem, several issues came up.&lt;/P&gt;&lt;P&gt;1. Why can't I include the assignment statement 'combined'' from the Set learn.blood?&lt;/P&gt;&lt;P&gt;2. Why don't the output statement generate subset_A and subset_B as written in the code below? When I proc print subset_?A and subset_B SAS tells me that they do not exist. Thanks for your help.&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 = Sum(.001*WBC + RBC) ; 
	Where Gender = 'Female' AND BloodType = 'AB' ; 
		 Output = Subset_A ; 
	Where Gender = 'Female' AND BloodType = 'AB' AND Combined ge 14 ; 
		 Output = Subset_B ; 
run ; 


Proc Print data=Subset_A noobs ; 
run ; 

Proc Print data=Subset_B noobs ; 
run ; &lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Apr 2018 16:41:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Several-things-regarding-output-and-assigment-statements/m-p/456949#M115808</guid>
      <dc:creator>ManitobaMoose</dc:creator>
      <dc:date>2018-04-24T16:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: Several things regarding output and assigment statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Several-things-regarding-output-and-assigment-statements/m-p/456950#M115809</link>
      <description>&lt;P&gt;I should also include the original data set learn.blood. It is below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data learn.blood;
   length Gender $ 6 BloodType $ 2 AgeGroup $ 5;
   input Subject 
         Gender 
         BloodType 
         AgeGroup
         WBC 
         RBC 
         Chol;
   label Gender = "Gender"
         BloodType = "Blood Type"
         AgeGroup = "Age Group"
         Chol = "Cholesterol";
Datalines ; 
1    Female AB Young 7710   7.4  258
2    Male   AB Old   6560   4.7  .
3    Male   A  Young 5690   7.53 184
4    Male   B  Old   6680   6.85 .
5    Male   A  Young .      7.72 187
6    Male   A  Old   6140   3.69 142
7    Female A  Young 6550   4.78 290
8    Male   O  Old   5200   4.96 151
9    Male   O  Young .      5.66 311
10   Female O  Young 7710   5.55 .
11   Male   B  Young .      5.62 152
12   Female O  Young 7410   5.85 241
13   Male   O  Young 5780   4.37 .&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Apr 2018 16:43:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Several-things-regarding-output-and-assigment-statements/m-p/456950#M115809</guid>
      <dc:creator>ManitobaMoose</dc:creator>
      <dc:date>2018-04-24T16:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: Several things regarding output and assigment statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Several-things-regarding-output-and-assigment-statements/m-p/456952#M115810</link>
      <description>&lt;P&gt;Below is the LOG:&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 = Sum(.001*WBC + RBC) ;
 70         Where Gender = 'Female' AND BloodType = 'AB' ;
 71          Output = Subset_A ;
 72         Where Gender = 'Female' AND BloodType = 'AB' AND Combined ge 14 ;
 ERROR: Variable Combined is not on file LEARN.BLOOD.
 73          Output = Subset_B ;
 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 11 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.01 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         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 96         &lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Apr 2018 16:44:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Several-things-regarding-output-and-assigment-statements/m-p/456952#M115810</guid>
      <dc:creator>ManitobaMoose</dc:creator>
      <dc:date>2018-04-24T16:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: Several things regarding output and assigment statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Several-things-regarding-output-and-assigment-statements/m-p/456958#M115815</link>
      <description>&lt;P&gt;use if instead of where&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Where Gender = 'Female' AND BloodType = 'AB' AND Combined ge 14 ;
 ERROR: Variable Combined is not on file LEARN.BLOOD.&lt;/PRE&gt;&lt;PRE&gt; if Gender = 'Female' AND BloodType = 'AB' AND Combined ge 14 ;&lt;/PRE&gt;&lt;PRE&gt;Data Review.Prob10_1 subset_a subset_b ; 
	Set Learn.Blood ; 
	Combined = Sum(.001*WBC + RBC) ; 
	if Gender = 'Female' AND BloodType = 'AB' ; 
		 Output Subset_A ; 
	else if Gender = 'Female' AND BloodType = 'AB' AND Combined ge 14 ; 
		 Output Subset_B ; 
run ; &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 17:04:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Several-things-regarding-output-and-assigment-statements/m-p/456958#M115815</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-04-24T17:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: Several things regarding output and assigment statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Several-things-regarding-output-and-assigment-statements/m-p/456973#M115825</link>
      <description>&lt;P&gt;Several features that you will need to learn ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can only output to data sets that&amp;nbsp; you are actually creating.&amp;nbsp; For example, if you want to output to Subset_A and Subset_B, your DATA statement needs to say:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data subset_a subset_b;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The WHERE statement can only refer to variables that exist in the incoming data, not to variable that&amp;nbsp; you create along the way.&amp;nbsp; When using multiple WHERE statements, the second one replaces the first.&amp;nbsp; The first has absolutely no impact on the program.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The OUTPUT statement doesn't use an equal sign.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The idea of converting to IF/THEN is a good one.&amp;nbsp; For example (assuming all the other mistakes are corrected):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if Gender = 'Female' AND BloodType = 'AB'&amp;nbsp; then output&amp;nbsp;Subset_A;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 17:21:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Several-things-regarding-output-and-assigment-statements/m-p/456973#M115825</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-04-24T17:21:01Z</dc:date>
    </item>
  </channel>
</rss>

