<?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: Running the same proc SQL on list of similar variables in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Running-the-same-proc-SQL-on-list-of-similar-variables/m-p/572517#M12344</link>
    <description>Can you convert your code to proc means instead? You cannot use an array within SQL so that would become a macro at best. But you can actually get what you want more easily from PROC MEANS + PROC CONTENTS, which will also do all variables at once. &lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Wed, 10 Jul 2019 20:37:27 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-07-10T20:37:27Z</dc:date>
    <item>
      <title>Running the same proc SQL on list of similar variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Running-the-same-proc-SQL-on-list-of-similar-variables/m-p/572513#M12343</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am attempting to create individual descriptive tables for a number of binary variables in my dataset. I've created the below proc sql code to generate the tables in the way that I would like them to look (see attached image for view of resulting table used for a binary variable named 'offerhdhp_any'). They need to include the variable name, variable label, value format, variable value, count (unweighted), count (weighted), percent (unweighted), and percent (weighted).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to generate this table for a list of similar binary variables in my dataset. Is there a way for this proc sql code to reference a list of variables instead of one single variable? If the answer is to use arrays, I would benefit from an example of how to use array within proc sql.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your help and your time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sql;
Create table temp2 as 
Select "OfferHdhp_Any" as VariableName, OfferHdhp_Any as ValueFormat, OfferHdhp_Any as VarValue format=3.0, 
count(*) as N_Unweighted format=comma10., sum(firmwgt) as N_Weighted format=comma10., 
count(OfferHdhp_Any)/(select count(OfferHdhp_Any) from temp)*100 as Percent_Unweighted /*format=percent8.2*/
From temp
Group by OfferHdhp_Any;
Create table temp3 as
Select VariableName, _LABEL_ as VariableLabel, ValueFormat, VarValue,-cmiss(VarValue)+1 as ValuePresent, N_Unweighted, N_Weighted, Percent_Unweighted 
From temp2
Inner join temp_labels
On temp2.VariableName=temp_labels._NAME_
order by VarValue; 
Create table temp4 as
Select VariableName, VariableLabel, ValueFormat, VarValue, N_Unweighted, N_Weighted, Percent_Unweighted, 
ValuePresent*N_Weighted / (sum(ValuePresent * N_Weighted))*100 as Percent_Weighted 
From temp3;
quit;

proc&amp;nbsp;print&amp;nbsp;data=temp4;&amp;nbsp;run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Jul 2019 20:32:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Running-the-same-proc-SQL-on-list-of-similar-variables/m-p/572513#M12343</guid>
      <dc:creator>user927</dc:creator>
      <dc:date>2019-07-10T20:32:01Z</dc:date>
    </item>
    <item>
      <title>Re: Running the same proc SQL on list of similar variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Running-the-same-proc-SQL-on-list-of-similar-variables/m-p/572517#M12344</link>
      <description>Can you convert your code to proc means instead? You cannot use an array within SQL so that would become a macro at best. But you can actually get what you want more easily from PROC MEANS + PROC CONTENTS, which will also do all variables at once. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 10 Jul 2019 20:37:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Running-the-same-proc-SQL-on-list-of-similar-variables/m-p/572517#M12344</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-10T20:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: Running the same proc SQL on list of similar variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Running-the-same-proc-SQL-on-list-of-similar-variables/m-p/572518#M12345</link>
      <description>&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Library-Datasets-Summary-Macro-DATA-SPECS/ta-p/544757" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Library-Datasets-Summary-Macro-DATA-SPECS/ta-p/544757&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Maybe this already written macro is useful, just include only the variables you want analyzed?</description>
      <pubDate>Wed, 10 Jul 2019 20:38:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Running-the-same-proc-SQL-on-list-of-similar-variables/m-p/572518#M12345</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-10T20:38:12Z</dc:date>
    </item>
  </channel>
</rss>

