<?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: Conditional Transpose in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Transpose/m-p/826427#M326433</link>
    <description>&lt;P&gt;I think you would have to do this conditional transpose with a macro, or with a macro %IF statement. In this example, I am looking for the number of observations in SASHELP.CLASS. Naturally you would replace SASHELP and CLASS with the actual libname and data set name. (Note: if the data set is in the WORK library, you have to use &lt;FONT face="courier new,courier"&gt;libname="WORK"&lt;/FONT&gt; in your SQL WHERE clause).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro cond_transp;
    proc sql;
         select nobs into :nobs from dictionary.tables where libname="SASHELP" and memname="CLASS";
    quit;
    %if &amp;amp;nobs&amp;gt;0 %then %do;
        proc transpose data= ...;
            /* Other proc transpose statements go here */
         run;
    %end;
%mend;
%cond_transp&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 01 Aug 2022 13:00:23 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-08-01T13:00:23Z</dc:date>
    <item>
      <title>Conditional Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Transpose/m-p/826423#M326430</link>
      <description>&lt;P&gt;i want to transpose the dataset with the condition.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if there is no observation available in dataset only variable is present then no transpose .&lt;/P&gt;&lt;P&gt;and if observation is present then transpose the dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help me in this.&lt;/P&gt;&lt;P&gt;Thanks in advance.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 12:42:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Transpose/m-p/826423#M326430</guid>
      <dc:creator>roshnigupta1602</dc:creator>
      <dc:date>2022-08-01T12:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Transpose/m-p/826426#M326432</link>
      <description>&lt;P&gt;Query DICTIONARY.TABLES, then execute code conditionally:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let count = 0;

proc sql noprint;
select nobs into :count
from dictionary.tables
where libname = "YOURLIB" and memname = "YOURDATASET";
quit;

% if &amp;amp;count. gt 0
%then %do;
  /* transpose code */
%end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Aug 2022 12:59:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Transpose/m-p/826426#M326432</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-08-01T12:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Transpose/m-p/826427#M326433</link>
      <description>&lt;P&gt;I think you would have to do this conditional transpose with a macro, or with a macro %IF statement. In this example, I am looking for the number of observations in SASHELP.CLASS. Naturally you would replace SASHELP and CLASS with the actual libname and data set name. (Note: if the data set is in the WORK library, you have to use &lt;FONT face="courier new,courier"&gt;libname="WORK"&lt;/FONT&gt; in your SQL WHERE clause).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro cond_transp;
    proc sql;
         select nobs into :nobs from dictionary.tables where libname="SASHELP" and memname="CLASS";
    quit;
    %if &amp;amp;nobs&amp;gt;0 %then %do;
        proc transpose data= ...;
            /* Other proc transpose statements go here */
         run;
    %end;
%mend;
%cond_transp&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 13:00:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Transpose/m-p/826427#M326433</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-08-01T13:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Transpose/m-p/826428#M326434</link>
      <description>&lt;P&gt;Note that, with a reasonably recent maintenance level of SAS 9.4, you can use %IF %THEN %DO - %END in open code, so you do not need a macro definition.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Aug 2022 13:03:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Transpose/m-p/826428#M326434</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-08-01T13:03:44Z</dc:date>
    </item>
  </channel>
</rss>

