<?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: Improve on Npar1way looping in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Improve-on-Npar1way-looping/m-p/131293#M35694</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Show some sample data with a few variables and enough obs to demonstrate the problem data and good data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you will want to transpose the variables to observations so you can run PROC NPAR1WAY by "variable name";&amp;nbsp; this should be easier and faster.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 01 Jun 2012 21:32:52 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2012-06-01T21:32:52Z</dc:date>
    <item>
      <title>Improve on Npar1way looping</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Improve-on-Npar1way-looping/m-p/131292#M35693</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am analyzing differences in data generated by different surveys. I have a couple of thousand variables and 10 survey versions. I compare variable by variable with proc npar1way, and I want to automate this procedure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem with npar1way is that it quits as soon it discovers a variable having values with only one level at the chosen class variable. The procedure does not continue, but quits instead. So it seems I need to take away those variables in the first place.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example of doing this, but it is not fool proof, because the "proc tabulate" adds a "_N" at the end of all variable&amp;nbsp; names. This macro will fail on variables already being 32 characters wide. Can it be improved or made over?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro qc_loopitem(module);&lt;BR /&gt;title &amp;amp;module;&lt;BR /&gt;data npar1way_&amp;amp;module (keep = &amp;amp;module: survey_version); set x; run;&lt;BR /&gt;%charToNumeric(work, npar1way_&amp;amp;module, &amp;amp;module);&lt;/P&gt;&lt;P&gt;proc tabulate data = npar1way_&amp;amp;module order = freq out = tmp_npar1way_&amp;amp;module;&lt;BR /&gt;class survey_version;&lt;BR /&gt;var &amp;amp;module:;&lt;BR /&gt;table survey_version, n * &amp;amp;module:;&lt;BR /&gt;run;&lt;BR /&gt;data tmp_npar1way_&amp;amp;module; set tmp_npar1way_&amp;amp;module; array module(*) &amp;amp;module:; do i = 1 to dim(module); call symput(cat("mod", i), ' '); call symput('n', i); if module&lt;I&gt; = 0 then call symput(cat("mod", i), vname(module&lt;I&gt;)); end; run;&lt;BR /&gt;%macro qc_dropvar; data tmp_npar1way_&amp;amp;module (drop = %do i = 1 %to &amp;amp;n; &amp;amp;&amp;amp;mod&amp;amp;i %end;); set tmp_npar1way_&amp;amp;module; run; %mend; %qc_dropvar;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;BR /&gt;select substr(trim(name), 1, index(name, '_N') - 1) into :modulestr separated by ' ' &lt;BR /&gt;from dictionary.columns where libname = 'WORK' and memname = "%upcase(tmp_npar1way_&amp;amp;module)" and (name like "&amp;amp;module.%");&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc npar1way data = npar1way_&amp;amp;module wilcoxon median;&lt;/P&gt;&lt;P&gt;class survey_version;&lt;BR /&gt;var &amp;amp;modulestr:;&lt;BR /&gt;output out = npar1way_&amp;amp;module;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro qc_loop;&lt;BR /&gt;%do i = 1 %to %sysfunc(countw(&amp;amp;ka_modules)); %qc_loopitem(%scan(&amp;amp;ka_modules, &amp;amp;i, ' ')); %end;&lt;BR /&gt;data npar1way; set npar1way_:; run;&lt;BR /&gt;proc datasets lib = work nolist; delete npar1way_: tmp_npar1way_:; run; quit;&lt;BR /&gt;%mend;&lt;BR /&gt;%qc_loop;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2012 20:47:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Improve-on-Npar1way-looping/m-p/131292#M35693</guid>
      <dc:creator>blackraven</dc:creator>
      <dc:date>2012-06-01T20:47:42Z</dc:date>
    </item>
    <item>
      <title>Re: Improve on Npar1way looping</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Improve-on-Npar1way-looping/m-p/131293#M35694</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Show some sample data with a few variables and enough obs to demonstrate the problem data and good data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you will want to transpose the variables to observations so you can run PROC NPAR1WAY by "variable name";&amp;nbsp; this should be easier and faster.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2012 21:32:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Improve-on-Npar1way-looping/m-p/131293#M35694</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2012-06-01T21:32:52Z</dc:date>
    </item>
  </channel>
</rss>

