<?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: Proc report in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-report/m-p/481227#M71602</link>
    <description>&lt;P&gt;You can't give a character value to a numeric variable. You ought to assign a format to A and B when they are missing, and the format should make the missing appear as "N/A".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think&amp;nbsp;another problem is that n_obs is not listed in the COLUMNS statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;UNTESTED CODE&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    value myfmt .='N/A' ;
run;
proc report nowd data = data;
		column (name n_obs a b);
		define name / display "Name";
                define n_obs/display noprint;
		define a / display "A" format=myfmt.;
		define B / display "B" format=myfmt.;
		compute A;
			if name = "X" and N_obs &amp;lt;= 10 then A = .;
		endcomp;
		compute B;
			if name = "X" and N_obs &amp;lt;= 10 then B = .;
		endcomp;
	%end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 25 Jul 2018 19:04:56 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2018-07-25T19:04:56Z</dc:date>
    <item>
      <title>Proc report</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-report/m-p/481219#M71600</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset composed of&amp;nbsp;1 character (name)&amp;nbsp;and 3 numeric variables (a b N_obs). I want to change a and b values to N/A if N_obs is lower than 10 and name = "X".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc report nowd data = data;
		column (name a b);
		define name / display "Name";
		define a / display "A";
		define B / display "B";
		compute A;
			if name = "X" and N_obs &amp;lt;= 10 then A = "N/A";
		endcomp;
		compute B;
			if name = "X" and N_obs &amp;lt;= 10 then B = "N/A";
		endcomp;
	%end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yet, if name = X and N_obs &amp;lt;= 10 then it gives me A and B = .&lt;/P&gt;&lt;P&gt;I guess this is because A and B are numeric variables. But, would there be a way to replace by N/A instead of .?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 18:28:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-report/m-p/481219#M71600</guid>
      <dc:creator>Shawn08</dc:creator>
      <dc:date>2018-07-25T18:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-report/m-p/481227#M71602</link>
      <description>&lt;P&gt;You can't give a character value to a numeric variable. You ought to assign a format to A and B when they are missing, and the format should make the missing appear as "N/A".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think&amp;nbsp;another problem is that n_obs is not listed in the COLUMNS statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;UNTESTED CODE&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    value myfmt .='N/A' ;
run;
proc report nowd data = data;
		column (name n_obs a b);
		define name / display "Name";
                define n_obs/display noprint;
		define a / display "A" format=myfmt.;
		define B / display "B" format=myfmt.;
		compute A;
			if name = "X" and N_obs &amp;lt;= 10 then A = .;
		endcomp;
		compute B;
			if name = "X" and N_obs &amp;lt;= 10 then B = .;
		endcomp;
	%end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Jul 2018 19:04:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-report/m-p/481227#M71602</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-25T19:04:56Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-report/m-p/481232#M71603</link>
      <description>&lt;P&gt;Hi:&lt;BR /&gt; You CANNOT test N_OBS if it is not on the COLUMN statement -- PROC REPORT only has visibility of the variables on the COLUMN statement -- it has NO visibility of variables in the data set. If you want to use a variable, but not show the variable, then you use the NOPRINT option on the DEFINE statement.&lt;BR /&gt;&lt;BR /&gt;Also, the placement of your %end is troublesome because this implies that there is more to your code than you're showing.&lt;BR /&gt;&lt;BR /&gt; Also, since NAME is to the left of A and B in the COLUMN statement, you can test NAME in the COMPUTE blocks, but you cannot test N_OBS unless it were also to the LEFT of A and B:&lt;BR /&gt;&lt;FONT size="3" color="#FF0000"&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;column name n_obs a b;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;And, if N_OBS is numeric, which your code implies, then N_OBS would have to also have a usage of DISPLAY in the DEFINE statement in order for your existing code to work.&lt;BR /&gt;&lt;BR /&gt; Without data, no one can run your code. And with the %end there, your code would cause an error message anyway. And, I completely missed that A and B were numeric...you'll have to make that change with a user defined format and a CALL DEFINE statement.&lt;BR /&gt;&lt;BR /&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 19:12:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-report/m-p/481232#M71603</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2018-07-25T19:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: Proc report</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-report/m-p/481235#M71604</link>
      <description>&lt;P&gt;Why is there an %END statement in there?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 19:10:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-report/m-p/481235#M71604</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-07-25T19:10:24Z</dc:date>
    </item>
  </channel>
</rss>

