<?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: Replacing flags with variable names and removing leading character in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replacing-flags-with-variable-names-and-removing-leading/m-p/665928#M199179</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID$ CC1	CC2	CC6	CC8	CC9	CC100	CC108;
cards;
123 1 0 0 0 0 1 0
124 0 1 0 0 0 1 0
125 1 0 0 1 0 0 0
;
run;

data want;
set have;
array C_[*]  CC:;

do i = 1 to dim(C_);
	if C_[i] &amp;gt; 0 then 
		COND_C=input(compress(vname(C_[i]),'CC'),8.);
	else continue;
	output;
end;

drop CC:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 29 Jun 2020 21:41:35 GMT</pubDate>
    <dc:creator>r_behata</dc:creator>
    <dc:date>2020-06-29T21:41:35Z</dc:date>
    <item>
      <title>Replacing flags with variable names and removing leading character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-flags-with-variable-names-and-removing-leading/m-p/665922#M199175</link>
      <description>&lt;P&gt;I have a data set that's been transposed already. I'm trying to find a way to replace the 1's with the numeric value it corresponds to in the variable field. I'm trying to un-transpose the variable and make the table long and skinny rather than wide. I'm also trying to replace the variable names with one name as 'COND_C'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are roughly 90 variables that start at CC1 and end in CC189. I tried it with an if statement but it did not capture it correctly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 384pt;" border="0" width="512" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl65" style="height: 15.0pt; width: 48pt;"&gt;ID&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-left: none; width: 48pt;"&gt;CC1&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-left: none; width: 48pt;"&gt;CC2&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-left: none; width: 48pt;"&gt;CC6&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-left: none; width: 48pt;"&gt;CC8&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-left: none; width: 48pt;"&gt;CC9&lt;/TD&gt;
&lt;TD width="64" class="xl66" style="border-left: none; width: 48pt;"&gt;CC100&lt;/TD&gt;
&lt;TD width="64" class="xl66" style="border-left: none; width: 48pt;"&gt;CC108&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;123&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-left: none;"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;124&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;125&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what I would like the output to look like.&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="123"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;ID&lt;/TD&gt;
&lt;TD width="59"&gt;COND_C&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;123&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;123&lt;/TD&gt;
&lt;TD&gt;100&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;124&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;124&lt;/TD&gt;
&lt;TD&gt;100&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;125&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;125&lt;/TD&gt;
&lt;TD&gt;8&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Mon, 29 Jun 2020 21:26:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-flags-with-variable-names-and-removing-leading/m-p/665922#M199175</guid>
      <dc:creator>bknitch</dc:creator>
      <dc:date>2020-06-29T21:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing flags with variable names and removing leading character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-flags-with-variable-names-and-removing-leading/m-p/665923#M199176</link>
      <description>&lt;P&gt;Do a wide to long proc transpose and filter out all the 0's.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=want(where=(col1 ne 0) rename = _name_ = cond_c);
by ID;
var CC1-CC189;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Jun 2020 21:58:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-flags-with-variable-names-and-removing-leading/m-p/665923#M199176</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-29T21:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing flags with variable names and removing leading character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-flags-with-variable-names-and-removing-leading/m-p/665928#M199179</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID$ CC1	CC2	CC6	CC8	CC9	CC100	CC108;
cards;
123 1 0 0 0 0 1 0
124 0 1 0 0 0 1 0
125 1 0 0 1 0 0 0
;
run;

data want;
set have;
array C_[*]  CC:;

do i = 1 to dim(C_);
	if C_[i] &amp;gt; 0 then 
		COND_C=input(compress(vname(C_[i]),'CC'),8.);
	else continue;
	output;
end;

drop CC:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Jun 2020 21:41:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-flags-with-variable-names-and-removing-leading/m-p/665928#M199179</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2020-06-29T21:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing flags with variable names and removing leading character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replacing-flags-with-variable-names-and-removing-leading/m-p/665934#M199184</link>
      <description>This was perfect, thank you for this!</description>
      <pubDate>Mon, 29 Jun 2020 21:58:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replacing-flags-with-variable-names-and-removing-leading/m-p/665934#M199184</guid>
      <dc:creator>bknitch</dc:creator>
      <dc:date>2020-06-29T21:58:08Z</dc:date>
    </item>
  </channel>
</rss>

