<?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: Create dummy dataset by age group and by category and by categorical values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-dummy-dataset-by-age-group-and-by-category-and-by/m-p/940655#M369190</link>
    <description>data want;&lt;BR /&gt;input AAGEGR1n TEXTn TEXT1n TEXT2n TEXT3n;&lt;BR /&gt;datalines;&lt;BR /&gt;1 1 1 1 1&lt;BR /&gt;1 1 1 1 0&lt;BR /&gt;1 1 1 2 1&lt;BR /&gt;1 1 1 2 2&lt;BR /&gt;1 1 1 2 3&lt;BR /&gt;1 1 1 2 4&lt;BR /&gt;1 1 1 2 5&lt;BR /&gt;1 1 1 2 6&lt;BR /&gt;1 1 1 2 7&lt;BR /&gt;1 1 1 2 8&lt;BR /&gt;1 1 1 3 1&lt;BR /&gt;1 1 1 3 2&lt;BR /&gt;1 1 1 3 3&lt;BR /&gt;1 1 1 3 4&lt;BR /&gt;1 1 1 3 5&lt;BR /&gt;1 1 1 3 6&lt;BR /&gt;1 1 1 3 7&lt;BR /&gt;1 1 1 3 8&lt;BR /&gt;1 1 1 4 1&lt;BR /&gt;1 1 1 4 0&lt;BR /&gt;;&lt;BR /&gt;;&lt;BR /&gt;run;</description>
    <pubDate>Fri, 23 Aug 2024 19:30:36 GMT</pubDate>
    <dc:creator>chinna0369</dc:creator>
    <dc:date>2024-08-23T19:30:36Z</dc:date>
    <item>
      <title>Create dummy dataset by age group and by category and by categorical values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-dummy-dataset-by-age-group-and-by-category-and-by/m-p/940649#M369188</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a dummy dataset for below data and I have provided my code as well. I have 20 records in my desired dataset but I am getting only 8 records when try to create dummy same like that. I am unable to create it by groups. Can you help me with this where I am doing wrong?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have;
input AAGEGR1	$1-23 TEXT $24-40	TEXT1 $41-89 TEXT2	$90-126 TEXT3 $127-150;
datalines;
Age group: 12-17 years	First Assessment	Mini-Tablets Crushed and Added to Food and Drink	Any Unpleasant After Taste	            No
Age group: 12-17 years	First Assessment	Mini-Tablets Crushed and Added to Food and Drink	Any Unpleasant After Taste	            Yes
Age group: 12-17 years	First Assessment	Mini-Tablets Crushed and Added to Food and Drink	How Easy to Take Other Oral Meds [2]	1
Age group: 12-17 years	First Assessment	Mini-Tablets Crushed and Added to Food and Drink	How Easy to Take Other Oral Meds [2]	2
Age group: 12-17 years	First Assessment	Mini-Tablets Crushed and Added to Food and Drink	How Easy to Take Other Oral Meds [2]	3
Age group: 12-17 years	First Assessment	Mini-Tablets Crushed and Added to Food and Drink	How Easy to Take Other Oral Meds [2]	4
Age group: 12-17 years	First Assessment	Mini-Tablets Crushed and Added to Food and Drink	How Easy to Take Other Oral Meds [2]	5
Age group: 12-17 years	First Assessment	Mini-Tablets Crushed and Added to Food and Drink	How Easy to Take Other Oral Meds [2]	Composite Evaluation [a]
Age group: 12-17 years	First Assessment	Mini-Tablets Crushed and Added to Food and Drink	How Easy to Take Other Oral Meds [2]	OK or Better (&amp;gt;=3)
Age group: 12-17 years	First Assessment	Mini-Tablets Crushed and Added to Food and Drink	How Easy to Take Other Oral Meds [2]	Worse than OK (&amp;lt;3)
Age group: 12-17 years	First Assessment	Mini-Tablets Crushed and Added to Food and Drink	How Easy to Take Study Drug [2]	        1
Age group: 12-17 years	First Assessment	Mini-Tablets Crushed and Added to Food and Drink	How Easy to Take Study Drug [2]	        2
Age group: 12-17 years	First Assessment	Mini-Tablets Crushed and Added to Food and Drink	How Easy to Take Study Drug [2]	        3
Age group: 12-17 years	First Assessment	Mini-Tablets Crushed and Added to Food and Drink	How Easy to Take Study Drug [2]	        4
Age group: 12-17 years	First Assessment	Mini-Tablets Crushed and Added to Food and Drink	How Easy to Take Study Drug [2]	        5
Age group: 12-17 years	First Assessment	Mini-Tablets Crushed and Added to Food and Drink	How Easy to Take Study Drug [2]	        Composite Evaluation [a]
Age group: 12-17 years	First Assessment	Mini-Tablets Crushed and Added to Food and Drink	How Easy to Take Study Drug [2]	        OK or Better (&amp;gt;=3)
Age group: 12-17 years	First Assessment	Mini-Tablets Crushed and Added to Food and Drink	How Easy to Take Study Drug [2]	        Worse than OK (&amp;lt;3)
Age group: 12-17 years	First Assessment	Mini-Tablets Crushed and Added to Food and Drink	Swallow the Dose	                    No
Age group: 12-17 years	First Assessment	Mini-Tablets Crushed and Added to Food and Drink	Swallow the Dose	                    Yes
;
run;

data want;
	do aagegr1n=1;
		do textn=1;
			do text1n=1;
				do text2n=1,2,3,4;
					do text3n=1,2;
	output;
					end;
				end;
			end;
		end;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Below is the desired dataset:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data want;
input AAGEGR1n TEXTn TEXT1n TEXT2n TEXT3n;
datalines;
1 1 1 1 1
1 1 1 1 0
1 1 1 2 1
1 1 1 2 2
1 1 1 2 3
1 1 1 2 4
1 1 1 2 5
1 1 1 2 6
1 1 1 2 7
1 1 1 2 8
1 1 1 3 1
1 1 1 3 2
1 1 1 3 3
1 1 1 3 4
1 1 1 3 5
1 1 1 3 6
1 1 1 3 7
1 1 1 3 8
1 1 1 4 1
1 1 1 4 0
;
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Chinna&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2024 19:31:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-dummy-dataset-by-age-group-and-by-category-and-by/m-p/940649#M369188</guid>
      <dc:creator>chinna0369</dc:creator>
      <dc:date>2024-08-23T19:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: Create dummy dataset by age group and by category and by categorical values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-dummy-dataset-by-age-group-and-by-category-and-by/m-p/940652#M369189</link>
      <description>&lt;P&gt;Could you please provide a quick sample of a few records of the desired output (want)?&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2024 18:54:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-dummy-dataset-by-age-group-and-by-category-and-by/m-p/940652#M369189</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2024-08-23T18:54:15Z</dc:date>
    </item>
    <item>
      <title>Re: Create dummy dataset by age group and by category and by categorical values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-dummy-dataset-by-age-group-and-by-category-and-by/m-p/940655#M369190</link>
      <description>data want;&lt;BR /&gt;input AAGEGR1n TEXTn TEXT1n TEXT2n TEXT3n;&lt;BR /&gt;datalines;&lt;BR /&gt;1 1 1 1 1&lt;BR /&gt;1 1 1 1 0&lt;BR /&gt;1 1 1 2 1&lt;BR /&gt;1 1 1 2 2&lt;BR /&gt;1 1 1 2 3&lt;BR /&gt;1 1 1 2 4&lt;BR /&gt;1 1 1 2 5&lt;BR /&gt;1 1 1 2 6&lt;BR /&gt;1 1 1 2 7&lt;BR /&gt;1 1 1 2 8&lt;BR /&gt;1 1 1 3 1&lt;BR /&gt;1 1 1 3 2&lt;BR /&gt;1 1 1 3 3&lt;BR /&gt;1 1 1 3 4&lt;BR /&gt;1 1 1 3 5&lt;BR /&gt;1 1 1 3 6&lt;BR /&gt;1 1 1 3 7&lt;BR /&gt;1 1 1 3 8&lt;BR /&gt;1 1 1 4 1&lt;BR /&gt;1 1 1 4 0&lt;BR /&gt;;&lt;BR /&gt;;&lt;BR /&gt;run;</description>
      <pubDate>Fri, 23 Aug 2024 19:30:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-dummy-dataset-by-age-group-and-by-category-and-by/m-p/940655#M369190</guid>
      <dc:creator>chinna0369</dc:creator>
      <dc:date>2024-08-23T19:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: Create dummy dataset by age group and by category and by categorical values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-dummy-dataset-by-age-group-and-by-category-and-by/m-p/940656#M369191</link>
      <description>&lt;P&gt;I'm not quite sure what this is useful for but if this Want data set is supposed to have a "structure" similar to the Have you do not have as many values of Text3n in Want as there are values of Text3 in the have data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: When I run your code a written it does not produce what I think you expect for a result because there are&lt;/P&gt;
&lt;P&gt;some TAB characters and the resulting column counts don't quite match that input statement. After replacing the tabs...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your Have data set has 10 different values for Text3. If you are trying to simulate that you need more values of Text3n. &lt;STRONG&gt;HOWEVER&lt;/STRONG&gt;, of the Text2 values&amp;nbsp; "Any Unpleasant After Taste" and "Swallow the Dose" are only associated with the 'Yes' and 'No' of Text3, and the "How Easy to Take Other Oral Meds [2]" and "How Easy to Take Study Drug [2]" are associated with the other 8 values of Text3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which means, if I understand what you want, something more like: (ugly code indents because I'm too lazy to clean up the different TAB treatment of the forum software vs my editor settings for this many indents)&lt;/P&gt;
&lt;PRE&gt;data want;
	do aagegr1n=1;
		do textn=1;
			do text1n=1;
				do text2n=1,2,3,4;
               if text2n in (1,4) then do;
                   do text3n= 1,2;
                     output;
                   end;
               end;
               else if text2n in (2,3) then do;
                    do text3n= 3 to 10;
                       output;
                     end;
					end;
				end;
			end;
		end;
	end;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 19:55:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-dummy-dataset-by-age-group-and-by-category-and-by/m-p/940656#M369191</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-08-27T19:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: Create dummy dataset by age group and by category and by categorical values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-dummy-dataset-by-age-group-and-by-category-and-by/m-p/940670#M369195</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/117414"&gt;@chinna0369&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;data want;&lt;BR /&gt;input AAGEGR1n TEXTn TEXT1n TEXT2n TEXT3n;&lt;BR /&gt;datalines;&lt;BR /&gt;1 1 1 1&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt; 1&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;FONT color="#000000"&gt;&amp;lt;= Does this 1 mean the same&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;1 1 1 1 0&lt;BR /&gt;1 1 1 2&lt;STRONG&gt;&lt;FONT color="#0000FF"&gt; 1&amp;nbsp; &lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT color="#000000"&gt;&amp;lt;=As this 1? In your text data, the text for the first 1 is 'No' but for the third line here is a digit 1.&lt;/FONT&gt;&lt;BR /&gt;31 1 1 2 2&lt;BR /&gt;1 1 1 2 3&lt;BR /&gt;1 1 1 2 4&lt;BR /&gt;1 1 1 2 5&lt;BR /&gt;1 1 1 2 6&lt;BR /&gt;1 1 1 2 7&lt;BR /&gt;1 1 1 2 8&lt;BR /&gt;1 1 1 3 1&lt;BR /&gt;1 1 1 3 2&lt;BR /&gt;1 1 1 3 3&lt;BR /&gt;1 1 1 3 4&lt;BR /&gt;1 1 1 3 5&lt;BR /&gt;1 1 1 3 6&lt;BR /&gt;1 1 1 3 7&lt;BR /&gt;1 1 1 3 8&lt;BR /&gt;1 1 1 4 1&lt;BR /&gt;1 1 1 4 0&lt;BR /&gt;;&lt;BR /&gt;;&lt;BR /&gt;run;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;To get your "code" you should consider the meaning of the characters...Regardless your, original Text3 has 10 different values. This coding only has 9.&lt;/P&gt;
&lt;P&gt;BTW, it is much more common to see 1 for Yes and 0 for No (or True/False).&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2024 21:00:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-dummy-dataset-by-age-group-and-by-category-and-by/m-p/940670#M369195</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-08-23T21:00:21Z</dc:date>
    </item>
  </channel>
</rss>

