<?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: How to output non missing variables from a list of variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-non-missing-variables-from-a-list-of-variables/m-p/852855#M337100</link>
    <description>&lt;P&gt;Seems kind of a silly thing to do.&amp;nbsp; But you could do it easily with two transposes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example;
   input subject  cigarettes cigars pipe vape;
datalines;
1001 1 1 0 0
1002 0 1 1 0
1003 0 1 1 1
;

proc transpose data=example out=tall;
  by subject;
  var cigarettes cigars pipe vape;
run;

proc transpose data=tall out=want(drop=_name_);
  where col1&amp;gt;0;
  by subject _name_;
  id _name_;
  var col1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs    subject    cigarettes    cigars    pipe    vape

 1       1001          1           .        .       .
 2       1001          .           1        .       .
 3       1002          .           1        .       .
 4       1002          .           .        1       .
 5       1003          .           1        .       .
 6       1003          .           .        1       .
 7       1003          .           .        .       1
&lt;/PRE&gt;</description>
    <pubDate>Mon, 09 Jan 2023 16:49:21 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-01-09T16:49:21Z</dc:date>
    <item>
      <title>How to output non missing variables from a list of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-non-missing-variables-from-a-list-of-variables/m-p/852853#M337098</link>
      <description>&lt;P&gt;I need help in figuring out how to output &amp;nbsp;a Subject that has two or more Tobacco types = 1 and &amp;nbsp;create a unique record for each Tobacco type&lt;/P&gt;&lt;P&gt;data example;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input subject&amp;nbsp; cigarettes cigars pipe vape;&l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&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 09 Jan 2023 16:39:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-non-missing-variables-from-a-list-of-variables/m-p/852853#M337098</guid>
      <dc:creator>gpv2000</dc:creator>
      <dc:date>2023-01-09T16:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to output non missing variables from a list of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-non-missing-variables-from-a-list-of-variables/m-p/852855#M337100</link>
      <description>&lt;P&gt;Seems kind of a silly thing to do.&amp;nbsp; But you could do it easily with two transposes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example;
   input subject  cigarettes cigars pipe vape;
datalines;
1001 1 1 0 0
1002 0 1 1 0
1003 0 1 1 1
;

proc transpose data=example out=tall;
  by subject;
  var cigarettes cigars pipe vape;
run;

proc transpose data=tall out=want(drop=_name_);
  where col1&amp;gt;0;
  by subject _name_;
  id _name_;
  var col1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs    subject    cigarettes    cigars    pipe    vape

 1       1001          1           .        .       .
 2       1001          .           1        .       .
 3       1002          .           1        .       .
 4       1002          .           .        1       .
 5       1003          .           1        .       .
 6       1003          .           .        1       .
 7       1003          .           .        .       1
&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Jan 2023 16:49:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-non-missing-variables-from-a-list-of-variables/m-p/852855#M337100</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-01-09T16:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to output non missing variables from a list of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-non-missing-variables-from-a-list-of-variables/m-p/852860#M337103</link>
      <description>Agree with Tom, this data structure does not make logical sense. What are you attempting to that makes you think you require this data structure? &lt;BR /&gt;&lt;BR /&gt;You mention, "output  a Subject that has two or more Tobacco types = 1" but your sample data does not include any observations that meet that criteria.</description>
      <pubDate>Mon, 09 Jan 2023 16:54:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-non-missing-variables-from-a-list-of-variables/m-p/852860#M337103</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-01-09T16:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to output non missing variables from a list of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-non-missing-variables-from-a-list-of-variables/m-p/852981#M337172</link>
      <description>I probably did not express clearly. Cigarettes, cigars, vape and pipes come under the umbrella of tobacco. If the subject uses any of these, it is captured as 1. I needed to output subjects that has 2 or more tobacco types as 2 records.</description>
      <pubDate>Tue, 10 Jan 2023 02:36:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-non-missing-variables-from-a-list-of-variables/m-p/852981#M337172</guid>
      <dc:creator>gpv2000</dc:creator>
      <dc:date>2023-01-10T02:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to output non missing variables from a list of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-non-missing-variables-from-a-list-of-variables/m-p/853091#M337212</link>
      <description>The solution you've selected will output regardless if it's 2 or 1.&lt;BR /&gt;&lt;BR /&gt;You can add a WHERE statement to filter it but I still feel this is probably a inefficient way to achieve a goal.</description>
      <pubDate>Tue, 10 Jan 2023 16:32:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-non-missing-variables-from-a-list-of-variables/m-p/853091#M337212</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-01-10T16:32:33Z</dc:date>
    </item>
  </channel>
</rss>

