<?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: Creating a data set of a smaller group of fields based on grouping labels stored in first record in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528897#M144421</link>
    <description>&lt;P&gt;Pleasure will be mine. In the mean time, can you please post a "&lt;STRONG&gt;&lt;U&gt;comprehensive&lt;/U&gt; &lt;/STRONG&gt;sample" explaining your need, so that we can avoid going back and forth. I could modify the code in one shot.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Jan 2019 21:19:27 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-01-21T21:19:27Z</dc:date>
    <item>
      <title>Creating a data set of a smaller group of fields based on grouping labels stored in first record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528836#M144376</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a contrived data set that has 9 fields of responses to examination questions. The questions have unique ids of 1, 2, 3, 4, 5, 6, 7, 8 &amp;amp; 9.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The 9 questions are grouped into blocks that are smaller modules of 3 questions. There are 3 blocks/modules of questions. The block/module ids are A, B, &amp;amp; C.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first record of the data set includes the question ids, and t&lt;SPAN&gt;he second record of the data set includes the block ids.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The information based on the first two records shows the specific questions grouped into each block/module.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The remaining records include examinees' responses to the questions, with 1 being answered correctly and 0 being answered incorrectly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is how the data set looks (Data Have):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1&amp;nbsp; 2 3&amp;nbsp; 4 5 6&amp;nbsp; 7 8&amp;nbsp; 9&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;A A A B B B C C C&lt;/P&gt;&lt;P&gt;1&amp;nbsp; 0 1&amp;nbsp; 0 1 0&amp;nbsp; 1 0&amp;nbsp; 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;0&amp;nbsp; 1 1&amp;nbsp; 1 0 0&amp;nbsp; 1 1&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;1&amp;nbsp; 1 1&amp;nbsp; 1 0 0&amp;nbsp; 0 0&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;Etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want to do is to create three separate data sets.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want a data set that has only the questions in block/module A.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want a data set that has only the questions in block/module B.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want a data set that has only the questions in block/module C.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This is what I want (Data Want):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output data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t;I think I could transpose the original data set, and work with it to select records for each block/module to create three output files, and then transpose those output files back so that the block/module id is in the first record for each of the three files.&amp;nbsp;But, that would require a number of transpose steps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am wondering if there is code that would be more concise &amp;amp; elegant that I can use in one DATA step that can be used together with a SAS macro. I need the code to generalize to a more realistic situation of starting with a data set that has 3000 fields of responses to exam questions grouped into 90 blocks/modules.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All I am hoping is that someone from the community would have a pretty decent idea of how to program the code for the single DATA step. I can then finish the code for the macro so that different block/module ids are specified and the DATA step can be executed for each block/module.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 19:00:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528836#M144376</guid>
      <dc:creator>ADouglas</dc:creator>
      <dc:date>2019-01-21T19:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set of a smaller group of fields based on grouping labels stored in first record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528844#M144381</link>
      <description>&lt;P&gt;How is the data stored? A SAS data set can not have 3 variables with the name &lt;STRONG&gt;A&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 18:27:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528844#M144381</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-01-21T18:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set of a smaller group of fields based on grouping labels stored in first record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528847#M144383</link>
      <description>&lt;P&gt;Thanks for asking the question, and clarifying a detail I overlooked.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let's say record 1 has the question ids, and record 2 has the block/module ids.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data I have:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1&amp;nbsp; 2 3&amp;nbsp; 4 5 6&amp;nbsp; 7 8&amp;nbsp; 9&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;A A A B B B C C C&lt;/P&gt;&lt;P&gt;1&amp;nbsp; 0 1&amp;nbsp; 0 1 0&amp;nbsp; 1 0&amp;nbsp; 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;0&amp;nbsp; 1 1&amp;nbsp; 1 0 0&amp;nbsp; 1 1&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;1&amp;nbsp; 1 1&amp;nbsp; 1 0 0&amp;nbsp; 0 0&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;Etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data I want.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output data set 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1&amp;nbsp; 2 3&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;A A A&amp;nbsp;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; 0 1&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;0&amp;nbsp; 1 1&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1&amp;nbsp; 1 1&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output data set 2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;4 5 6&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;B B B&amp;nbsp;&lt;/P&gt;&lt;P&gt;0 1 0&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 0 0&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 0 0&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Output data set 3.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;7 8&amp;nbsp; 9&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;C C C&lt;/P&gt;&lt;P&gt;1 0&amp;nbsp; 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 1&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;0 0&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;Etc.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 18:33:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528847#M144383</guid>
      <dc:creator>ADouglas</dc:creator>
      <dc:date>2019-01-21T18:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set of a smaller group of fields based on grouping labels stored in first record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528851#M144386</link>
      <description>Is your data in SAS data sets already or in text files to start with?</description>
      <pubDate>Mon, 21 Jan 2019 18:38:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528851#M144386</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-21T18:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set of a smaller group of fields based on grouping labels stored in first record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528853#M144388</link>
      <description>&lt;P&gt;The data will come to me as a .csv file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As per Draycut's question, I can have the IT professional store the block/module ids as the 2nd record, and the item ids as the first record, if need be?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 18:42:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528853#M144388</guid>
      <dc:creator>ADouglas</dc:creator>
      <dc:date>2019-01-21T18:42:35Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set of a smaller group of fields based on grouping labels stored in first record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528857#M144391</link>
      <description>&lt;P&gt;Will you always have that many columns or is that an example? Is this a more than one time process or one time?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd probably build a dynamic process, first read the first two records, determine how many you need and then read the rest. But it depends on how generic it needs to be. Not really sure why you need to split it either.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138057"&gt;@ADouglas&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The data will come to me as a .csv file.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As per Draycut's question, I can have the IT professional store the block/module ids as the 2nd record, and the item ids as the first record, if need be?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 18:48:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528857#M144391</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-21T18:48:16Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set of a smaller group of fields based on grouping labels stored in first record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528859#M144392</link>
      <description>&lt;P&gt;I receive semi-annually a data set with over 3000 variables. The code needs to be executed each time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The blocks/modules of questions need to be put into separate output files, and I have to conduct analysis for each file.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Aaron&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 18:52:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528859#M144392</guid>
      <dc:creator>ADouglas</dc:creator>
      <dc:date>2019-01-21T18:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set of a smaller group of fields based on grouping labels stored in first record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528864#M144397</link>
      <description>Thanks for clarifying. I forgot.</description>
      <pubDate>Mon, 21 Jan 2019 19:01:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528864#M144397</guid>
      <dc:creator>ADouglas</dc:creator>
      <dc:date>2019-01-21T19:01:15Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set of a smaller group of fields based on grouping labels stored in first record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528886#M144414</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138057"&gt;@ADouglas&lt;/a&gt;&amp;nbsp; Have fun with hashes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input A1 A2 A3 B1 B2 B3 C1 C2 C3;
cards;
1  2 3  4 5 6  7 8  9
1  0 1  0 1 0  1 0  1 
0  1 1  1 0 0  1 1  0
1  1 1  1 0 0  0 0  1
;
dm log 'clear';

data _null_ ;
  if _n_ = 1 then do ;
    declare hash h ;   
    declare hash hoh() ;  
    hoh.defineKey ("j") ;
    hoh.defineData ("h", "j") ;
	   hoh.defineDone () ;
	end ;
set have end = lr ;  
array t(*) a1--c3;
do i= 1 to dim(t);
k=mod(i,3);
if k=1 then 
	do;
		j=first(vname(t(i)));
		if hoh.find() ne 0 then 
		do ;  
   			 h = _new_ hash (multidata:"Y",ordered:'y') ;  
			 h.defineKey ('_n_') ; 
		     do  k1=i to i+2;
	    		h.defineData (vname(t(k1))) ;
			end;
			h.defineDone () ;
		    hoh.add() ; 
	   end; 
	  h.add(key:_n_, data:t(i),data:t(i+1),data:t(i+2)) ;  
   end ;
end;
if lr ;
  declare hiter ihoh ("hoh") ;  
  do while (ihoh.next() = 0) ;
     h.output (dataset:j) ;
  end ;
run ;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;NOTE: If memory is an issue, i can't help. A college student's help can go thus far only with the limited resources I have.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 20:54:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528886#M144414</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-21T20:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set of a smaller group of fields based on grouping labels stored in first record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528888#M144415</link>
      <description>&lt;P&gt;This works, bravo bravo.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I will need to study the code to understand it, and I'm not sure how fast it will be when there are 3000 plus variables and 90 plus blocks/modules.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, nonetheless, I'm sure it will come in handy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The solution does require a change for inputting the data, but nonetheless, it get's the job done.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!!&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 21:43:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528888#M144415</guid>
      <dc:creator>ADouglas</dc:creator>
      <dc:date>2019-01-21T21:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set of a smaller group of fields based on grouping labels stored in first record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528889#M144416</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138057"&gt;@ADouglas&lt;/a&gt;&amp;nbsp; If you could bear with me until tomorrow. I can possibly effiiciently test at my college lab. Today it's a holiday here in Chicago and I would only go back to Depaul lab tomorrow morning.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, if it's not urgent, I can efficiently test with rich samples and let you know or even make changes. Just&amp;nbsp; a one caveat, I do have a presentation on a case study tomorrow that I hope to pass as I haven't even started yet lol, so the timing of my response may not be consistent.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nonetheless, We the community(you included) are a SAS family. Feel free to reach out to us.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS I will explain how the code works tomorrow. Today I am little too busy preparing for the case study. Bear with me sir!&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 21:09:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528889#M144416</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-21T21:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set of a smaller group of fields based on grouping labels stored in first record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528891#M144417</link>
      <description>&lt;P&gt;Please finish your case study; and only if you have time, followup with me here.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is only one issue with your code, I think.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The number of modules can very year to year; and for a given year, the number of questions between modules varies.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My example didn't show these complexities. But, what you've done will work for a set of modules that have a fixed number of questions. I could very well be presented with such a scenario for another project.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I applaud your interest and motivation to respond while being a college student.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Take Care&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 21:16:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528891#M144417</guid>
      <dc:creator>ADouglas</dc:creator>
      <dc:date>2019-01-21T21:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set of a smaller group of fields based on grouping labels stored in first record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528894#M144419</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Just&amp;nbsp; a one caveat, I do have a presentation on a case study tomorrow that I hope to pass as I haven't even started yet lol, so the timing of my response may not be consistent.&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; Get off of here and go do your homework! &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 21:18:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528894#M144419</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-21T21:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set of a smaller group of fields based on grouping labels stored in first record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528897#M144421</link>
      <description>&lt;P&gt;Pleasure will be mine. In the mean time, can you please post a "&lt;STRONG&gt;&lt;U&gt;comprehensive&lt;/U&gt; &lt;/STRONG&gt;sample" explaining your need, so that we can avoid going back and forth. I could modify the code in one shot.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 21:19:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528897#M144421</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-21T21:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set of a smaller group of fields based on grouping labels stored in first record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528903#M144422</link>
      <description>&lt;P&gt;Hi Novinosrin,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you requested, below is a modification to the example that shows how the number of questions between modules vary.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data I have:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1&amp;nbsp; 2 3&amp;nbsp; 4 5 6&amp;nbsp; 7 8&amp;nbsp; 9&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;A A A A B B C C C&lt;/P&gt;&lt;P&gt;1&amp;nbsp; 0 1&amp;nbsp; 0 1 0&amp;nbsp; 1 0&amp;nbsp; 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;0&amp;nbsp; 1 1&amp;nbsp; 1 0 0&amp;nbsp; 1 1&amp;nbsp; 0&amp;nbsp;&lt;/P&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;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;7 8&amp;nbsp; 9&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;C C C&lt;/P&gt;&lt;P&gt;&amp;nbsp;1 0&amp;nbsp; 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;1 1&amp;nbsp; 0&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;0 0&amp;nbsp; 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;Etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But do your homework first !!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 21:28:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528903#M144422</guid>
      <dc:creator>ADouglas</dc:creator>
      <dc:date>2019-01-21T21:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set of a smaller group of fields based on grouping labels stored in first record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528905#M144424</link>
      <description>Do you actually have the 123456789 in your data set or are you adding that for clarity?</description>
      <pubDate>Mon, 21 Jan 2019 21:31:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528905#M144424</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-21T21:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set of a smaller group of fields based on grouping labels stored in first record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528909#M144426</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My example is somewhat contrived so it can be clear, and sufficiently informative so that I can modify the code of the solution to fit what actually occurs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each question id actually has between 6 to 7 characters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 21:35:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528909#M144426</guid>
      <dc:creator>ADouglas</dc:creator>
      <dc:date>2019-01-21T21:35:45Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set of a smaller group of fields based on grouping labels stored in first record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528915#M144431</link>
      <description>So you have something similar to those numbers in the first row?</description>
      <pubDate>Mon, 21 Jan 2019 21:42:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528915#M144431</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-21T21:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set of a smaller group of fields based on grouping labels stored in first record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528916#M144432</link>
      <description>&lt;P&gt;Yes&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 21:44:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/528916#M144432</guid>
      <dc:creator>ADouglas</dc:creator>
      <dc:date>2019-01-21T21:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set of a smaller group of fields based on grouping labels stored in first record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/529239#M144545</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138057"&gt;@ADouglas&lt;/a&gt;&amp;nbsp; Good afternoon, Please find the below modified code for the new updated source. It's 1:50 pm at Chicago right now. I haven't tested "extensively" as I managed to sneak peek on SAS communities during a break. However, I will later tonight if I can after my case study submission if I have time. I might grab a couple of pints on my way home :), so do expect some delays should you require any further changes lol&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have a good one!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*New updated source from ADouglas*/
data have;
input A1 A2 A3 A4 B5 B6 C7 C8 C9;
cards;
1  0 1  0 1 0  1 0  1 
0  1 1  1 0 0  1 1  0 
1  1 1  1 0 0  0 0  1 
;
dm log 'clear';
/*Modified code to handle varying series of vars*/
data _null_ ;
  if _n_ = 1 then do ;
    declare hash h ;   
    declare hash hoh() ;  
    hoh.defineKey ("j") ;
    hoh.defineData ("h", "j") ;
	hoh.defineDone () ;
	end ;
set have end = lr ;  
array t(*) a1--c9;
do i= 1 to dim(t);
  j=first(vname(t(i)));
  if  hoh.find() ne 0 then 
		do ;  
   			 h = _new_ hash (multidata:"Y",ordered:'y') ;  
			 h.defineKey ('_n_') ; 
			 do k=i by 1 while(first(vname(t(k)))=j and k&amp;lt;=dim(t));
			 	if first(vname(t(i)))=j then h.defineData (vname(t(k))) ;
				if k=dim(t) then  leave;
			 end;
			h.defineDone () ;
		    hoh.add() ; 
			h.add() ;  
	   end; 
	else  h.replace() ;  
end;
if lr ;
  declare hiter ihoh ("hoh") ;  
  do while (ihoh.next() = 0) ;
     h.output (dataset:j) ;
  end ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 19:48:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-data-set-of-a-smaller-group-of-fields-based-on/m-p/529239#M144545</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-22T19:48:04Z</dc:date>
    </item>
  </channel>
</rss>

