<?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: Change data set structure from &amp;quot;FROM_date&amp;quot; &amp;quot;Till_date&amp;quot; information to &amp;quot; in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Change-data-set-structure-from-quot-FROM-date-quot-quot-Till/m-p/621747#M182831</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The variable group is included. I made a copy of the code with a lot of comments to explain what is is giong on, so you can see why.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* DATA declares an output data set and specify variables to DROP from output;
DATA want (DROP = from to); 

	* SET declares input data set; 
	* SET also implies an automatic loop over the input data set, so the full program 
	*     is executed once for each observation in input;
	* SET brings all variables from the current input observation into the program,
	*     this includes the variable "group";
	SET have;

	* FORMAT is there only to display the output date in readable form;
	FORMAT date date9.;

	* DO starts a loop that runs for each observation. The variable "date" is incremented by 1&lt;BR /&gt;        from the value of "from" until it adds up to the value of "to";
	DO date = from to to;

		* OUTPUT writes all variables in the program to the output data set
			(excluding "from" and "to" named in the DROP option to DATA);
        * The result is that an output observation is written for each "date" 
			between "from" and "to" and repeated for all input observations;
		* The output includes the variable "date", because it it is declared in the DO statement, 
	          the variable "group", because it is read into the program in the SET statement;
		OUTPUT;

	* END ends the code to execute repeatedly in the DO loop for each input observation;
	end; 

* RUN ends the DATA step and thus the code to execute once for each input observation;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 02 Feb 2020 09:49:48 GMT</pubDate>
    <dc:creator>ErikLund_Jensen</dc:creator>
    <dc:date>2020-02-02T09:49:48Z</dc:date>
    <item>
      <title>Change data set structure from "FROM_date" "Till_date" information to "Date" information</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-data-set-structure-from-quot-FROM-date-quot-quot-Till/m-p/621611#M182747</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I have a summary table that contain for each interval of dates the group.(It is an external data set that I receive).&lt;/P&gt;
&lt;P&gt;I need to create from this summary table another summary table that contain information for each date what is the group.&lt;/P&gt;
&lt;P&gt;What is the best way to do it please?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="E2.PNG" style="width: 239px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/35795iEE7F9ACDF92F1FB9/image-size/large?v=v2&amp;amp;px=999" role="button" title="E2.PNG" alt="E2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Feb 2020 09:30:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-data-set-structure-from-quot-FROM-date-quot-quot-Till/m-p/621611#M182747</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-02-01T09:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: Change data set structure from "FROM_date" "Till_date" information to "</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-data-set-structure-from-quot-FROM-date-quot-quot-Till/m-p/621612#M182748</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can make use of the output statement. SAS outputs the current value of variables whenever an output statement is executed, so you can place the output statement in a loop over the interval and get an output observation for each iteration.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And please provide working code to create test input. Creating test data was much more work than answering your question,. Note also that it is a bad idea to use reserved words as variable names. The loop control information "i = from to to" doesn't look good, even if it works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
	from = '15oct2019'd; to = '19oct2019'd; group = 'a'; output;
	from = '20oct2019'd; to = '15nov2019'd; group = 'b'; output;
	from = '16oct2019'd; to = '05dec2019'd; group = 'c'; output;
	from = '06dec2019'd; to = '31dec2019'd; group = 'd'; output;
run;

data want (drop = from to); set have;
	format date date9.;
	do date = from to to;
		output;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 01 Feb 2020 10:00:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-data-set-structure-from-quot-FROM-date-quot-quot-Till/m-p/621612#M182748</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2020-02-01T10:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: Change data set structure from "FROM_date" "Till_date" information to "</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-data-set-structure-from-quot-FROM-date-quot-quot-Till/m-p/621616#M182751</link>
      <description>&lt;P&gt;Thank you so much!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Feb 2020 10:39:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-data-set-structure-from-quot-FROM-date-quot-quot-Till/m-p/621616#M182751</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-02-01T10:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: Change data set structure from "FROM_date" "Till_date" information to "</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-data-set-structure-from-quot-FROM-date-quot-quot-Till/m-p/621673#M182792</link>
      <description>&lt;P&gt;I didn't run the code because I don't have SAS at home.&lt;/P&gt;
&lt;P&gt;I just want to ask please If in your output there is also field "group"??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Feb 2020 20:27:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-data-set-structure-from-quot-FROM-date-quot-quot-Till/m-p/621673#M182792</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-02-01T20:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: Change data set structure from "FROM_date" "Till_date" information to "</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-data-set-structure-from-quot-FROM-date-quot-quot-Till/m-p/621747#M182831</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The variable group is included. I made a copy of the code with a lot of comments to explain what is is giong on, so you can see why.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* DATA declares an output data set and specify variables to DROP from output;
DATA want (DROP = from to); 

	* SET declares input data set; 
	* SET also implies an automatic loop over the input data set, so the full program 
	*     is executed once for each observation in input;
	* SET brings all variables from the current input observation into the program,
	*     this includes the variable "group";
	SET have;

	* FORMAT is there only to display the output date in readable form;
	FORMAT date date9.;

	* DO starts a loop that runs for each observation. The variable "date" is incremented by 1&lt;BR /&gt;        from the value of "from" until it adds up to the value of "to";
	DO date = from to to;

		* OUTPUT writes all variables in the program to the output data set
			(excluding "from" and "to" named in the DROP option to DATA);
        * The result is that an output observation is written for each "date" 
			between "from" and "to" and repeated for all input observations;
		* The output includes the variable "date", because it it is declared in the DO statement, 
	          the variable "group", because it is read into the program in the SET statement;
		OUTPUT;

	* END ends the code to execute repeatedly in the DO loop for each input observation;
	end; 

* RUN ends the DATA step and thus the code to execute once for each input observation;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 02 Feb 2020 09:49:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-data-set-structure-from-quot-FROM-date-quot-quot-Till/m-p/621747#M182831</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2020-02-02T09:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: Change data set structure from "FROM_date" "Till_date" information to "</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-data-set-structure-from-quot-FROM-date-quot-quot-Till/m-p/621914#M182909</link>
      <description>&lt;P&gt;Thank you so so much&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2020 12:28:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-data-set-structure-from-quot-FROM-date-quot-quot-Till/m-p/621914#M182909</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-02-03T12:28:41Z</dc:date>
    </item>
  </channel>
</rss>

