<?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: &amp;quot;If...then...delete;&amp;quot; issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/quot-If-then-delete-quot-issue/m-p/403793#M98138</link>
    <description>&lt;P&gt;If you just want PROC MEANS to generate the MEAN then tell it that.&amp;nbsp; If you add MEAN= to the OUTPUT statement then SAS will store the means into the variables with the same names as the input variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=AllEvents;
  class plotID;
  var logN2O logVWC Soil_N Soil_C SoilC_N
      LitterN LitterC LitterC_N pH_H2O pH_CaCl2 logNH4 logTN
  ;
  output out=plotmeans mean=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your data step has a number of problems. First you are not telling it what data to read. Second you are comparing two string literals in your IF statements that can never be equal.&amp;nbsp; You probably could have gotten it to work with code like this just use a subsetting IF instead of IF/THEN/DELETE.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data plotmeans;
  set plotmeans;
  if _stat_='MEAN';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 13 Oct 2017 04:35:47 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-10-13T04:35:47Z</dc:date>
    <item>
      <title>"If...then...delete;" issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-If-then-delete-quot-issue/m-p/403730#M98105</link>
      <description>&lt;P&gt;I want to run a PROC REG on some data with many variables. However, some of the variables were collected at the plot level while others were collected in transects within the plot. If i take the mean of the transect variables, that gives me a plot level variable that i can then use the PROC REG function on. However, if i use PROC MEANS to get the mean variable of these transect data points it also gives me N, MAX, MIN, and STD output. If i run PROC REG on the data generated by PROC MEANS it includes the 4 variables i mentioned in the regression, which i obviously don't want. So, i want to delete those 4 variables and have PROC REG use the MEAN variable exclusively.&lt;/P&gt;&lt;P&gt;proc means data=AllEvents;&lt;BR /&gt;class plotID;&lt;BR /&gt;var logN2O logVWC Soil_N Soil_C SoilC_N LitterN LitterC LitterC_N pH_H2O pH_CaCl2 logNH4 logTN;&lt;BR /&gt;output out=plotmeans;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data plotmeans;&lt;BR /&gt;if "_STAT_"="N"&amp;nbsp;then delete;&lt;BR /&gt;if&amp;nbsp;"_STAT_"="MAX" then delete;&lt;BR /&gt;if&amp;nbsp;"_STAT_"="MIN" then delete;&lt;BR /&gt;if&amp;nbsp;"_STAT_"="STD" then delete;&lt;BR /&gt;output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The proc means command works fine but the my "if...then...delete;" command doesn't work. It doesn't generate an error, but it does give me the message:&amp;nbsp;&lt;SPAN&gt; NOTE: Variable _STAT_ is uninitialized.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;How can i generate an output of the mean of the variables i'm interested in at the plot level that i can then run PROC REG with?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 23:35:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-If-then-delete-quot-issue/m-p/403730#M98105</guid>
      <dc:creator>AaronJ</dc:creator>
      <dc:date>2017-10-12T23:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: "If...then...delete;" issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-If-then-delete-quot-issue/m-p/403733#M98108</link>
      <description>&lt;P&gt;You can control the output in various ways. Look at the OUTPUT statement documentation for starters to select only the MEAN.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And then look at the STACKODS option to see if you want a different structure.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means ...;
....

output out=want mean = /autoname;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=...  MEAN STACKODS;
....
ods output summary=want_stacked;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Oct 2017 23:51:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-If-then-delete-quot-issue/m-p/403733#M98108</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-12T23:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: "If...then...delete;" issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-If-then-delete-quot-issue/m-p/403734#M98109</link>
      <description>&lt;P&gt;You need a set statement after the data statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;set plotmeans;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It reads the input data set into the data step.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 23:51:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-If-then-delete-quot-issue/m-p/403734#M98109</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2017-10-12T23:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: "If...then...delete;" issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quot-If-then-delete-quot-issue/m-p/403793#M98138</link>
      <description>&lt;P&gt;If you just want PROC MEANS to generate the MEAN then tell it that.&amp;nbsp; If you add MEAN= to the OUTPUT statement then SAS will store the means into the variables with the same names as the input variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=AllEvents;
  class plotID;
  var logN2O logVWC Soil_N Soil_C SoilC_N
      LitterN LitterC LitterC_N pH_H2O pH_CaCl2 logNH4 logTN
  ;
  output out=plotmeans mean=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your data step has a number of problems. First you are not telling it what data to read. Second you are comparing two string literals in your IF statements that can never be equal.&amp;nbsp; You probably could have gotten it to work with code like this just use a subsetting IF instead of IF/THEN/DELETE.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data plotmeans;
  set plotmeans;
  if _stat_='MEAN';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Oct 2017 04:35:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quot-If-then-delete-quot-issue/m-p/403793#M98138</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-13T04:35:47Z</dc:date>
    </item>
  </channel>
</rss>

