<?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 Create time ID variable with program (instead of using the point-and-click system) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-time-ID-variable-with-program-instead-of-using-the-point/m-p/233416#M308427</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dear SAS users,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS offers a point-and-click system to create a time ID variable from a certain starting date using a particular frequency (e.g. weeks, quarters, years).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since I need to do this proces repeatedly, I like to use a code as it makes things much easier. My data covers 1985-2005 and is divided into quarters (which gives 21 years * 4 quarters = 84 observations).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The date variable column should look like this (or any other number which can be formated into a date):&lt;/P&gt;&lt;P&gt;Date:&lt;/P&gt;&lt;P&gt;1985/1&lt;/P&gt;&lt;P&gt;1985/2&lt;/P&gt;&lt;P&gt;1985/3&lt;/P&gt;&lt;P&gt;1985/4&lt;/P&gt;&lt;P&gt;etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know how to write a code for this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rens (a postgraduate student in sociology)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 06 Nov 2015 12:38:24 GMT</pubDate>
    <dc:creator>Rens</dc:creator>
    <dc:date>2015-11-06T12:38:24Z</dc:date>
    <item>
      <title>Create time ID variable with program (instead of using the point-and-click system)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-time-ID-variable-with-program-instead-of-using-the-point/m-p/233416#M308427</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dear SAS users,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS offers a point-and-click system to create a time ID variable from a certain starting date using a particular frequency (e.g. weeks, quarters, years).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since I need to do this proces repeatedly, I like to use a code as it makes things much easier. My data covers 1985-2005 and is divided into quarters (which gives 21 years * 4 quarters = 84 observations).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The date variable column should look like this (or any other number which can be formated into a date):&lt;/P&gt;&lt;P&gt;Date:&lt;/P&gt;&lt;P&gt;1985/1&lt;/P&gt;&lt;P&gt;1985/2&lt;/P&gt;&lt;P&gt;1985/3&lt;/P&gt;&lt;P&gt;1985/4&lt;/P&gt;&lt;P&gt;etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know how to write a code for this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rens (a postgraduate student in sociology)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 12:38:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-time-ID-variable-with-program-instead-of-using-the-point/m-p/233416#M308427</guid>
      <dc:creator>Rens</dc:creator>
      <dc:date>2015-11-06T12:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: Create time ID variable with program (instead of using the point-and-click system)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-time-ID-variable-with-program-instead-of-using-the-point/m-p/233418#M308428</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have no idea about a point &amp;amp; click system, or what software you are using, but in base SAS you could do:&lt;/P&gt;
&lt;PRE&gt;data want;
  do year=1985 to 2005;&lt;BR /&gt;    do quater=1 to 4;&lt;BR /&gt;      year_quarter=cats(put(year,4.),"/",put(quater,1.));&lt;BR /&gt;      output;&lt;BR /&gt;    end;&lt;BR /&gt;  end;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;So a loop over your years, and then for each year, a loop over the quaters. &amp;nbsp;It may be possible to shrink the code somewhat, or use a procedure, but I feel the above code shows the process more clearly.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 13:28:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-time-ID-variable-with-program-instead-of-using-the-point/m-p/233418#M308428</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-11-06T13:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: Create time ID variable with program (instead of using the point-and-click system)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-time-ID-variable-with-program-instead-of-using-the-point/m-p/233419#M308429</link>
      <description>&lt;P&gt;You can use a YYQxw. format. I think that yyqs8. looks a lot like the format you want. The data will stay as a SAS date value, but it gives you the desired look.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002231398.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002231398.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 13:28:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-time-ID-variable-with-program-instead-of-using-the-point/m-p/233419#M308429</guid>
      <dc:creator>slangan</dc:creator>
      <dc:date>2015-11-06T13:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: Create time ID variable with program (instead of using the point-and-click system)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-time-ID-variable-with-program-instead-of-using-the-point/m-p/233423#M308430</link>
      <description>&lt;P&gt;Yes, I never have to deal with quaters, so I forget those formats. &amp;nbsp; To change the loop slightly to get:&lt;/P&gt;
&lt;PRE&gt;data want;
  do year_qtr=input("1985Q01",yyq9.) to input("2005Q04",yyq9.);
      output;
  end;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Nov 2015 13:35:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-time-ID-variable-with-program-instead-of-using-the-point/m-p/233423#M308430</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-11-06T13:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: Create time ID variable with program (instead of using the point-and-click system)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-time-ID-variable-with-program-instead-of-using-the-point/m-p/233428#M308431</link>
      <description>&lt;P&gt;Thank you very much. This second loop does does create a sas date variable (which can be formated like i want), but does it for every day. So I get more than 600000 observation, whereas only 84 are needed.&lt;BR /&gt;&lt;BR /&gt;The first loop creates a file with only 84 observation, but the 'year_quarter' variable is not formattable as a sas date. Normally I indeed use the yyqs8. format to change a sas date into the desired form (like this: format year_quarter yyqs8.; )&lt;BR /&gt;&lt;BR /&gt;Is there perhaps a solution? Many thanks again.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 14:14:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-time-ID-variable-with-program-instead-of-using-the-point/m-p/233428#M308431</guid>
      <dc:creator>Rens</dc:creator>
      <dc:date>2015-11-06T14:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: Create time ID variable with program (instead of using the point-and-click system)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-time-ID-variable-with-program-instead-of-using-the-point/m-p/233431#M308432</link>
      <description>&lt;P&gt;Well, my original code was creating a text field that looked like the data you had provided. &amp;nbsp;If you are ok with the SAS quarter value then change to:&lt;/P&gt;
&lt;PRE&gt;data want;
 do year=1985 to 2005;
   do quater=1 to 4;
     year_quarter=input(cats(put(year,4.),"Q",put(quater,1.)),yyq8.);
     output;
   end;
 end;
 format year_quarter yyq8.;
run;&lt;/PRE&gt;
&lt;P&gt;As for the second code,&amp;nbsp;will need to have a look, perhaps a by group or something. &amp;nbsp;Will post when I get a chance to look at it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 14:38:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-time-ID-variable-with-program-instead-of-using-the-point/m-p/233431#M308432</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-11-06T14:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: Create time ID variable with program (instead of using the point-and-click system)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-time-ID-variable-with-program-instead-of-using-the-point/m-p/233445#M308433</link>
      <description>Thanks! This is the solution. With this loop I can create a date ID variable and, subsequently, merge all my observations into it. I just checked to be sure, but the SAS time series procedures also recognize this date variable for different types of analyses.</description>
      <pubDate>Fri, 06 Nov 2015 15:20:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-time-ID-variable-with-program-instead-of-using-the-point/m-p/233445#M308433</guid>
      <dc:creator>Rens</dc:creator>
      <dc:date>2015-11-06T15:20:56Z</dc:date>
    </item>
  </channel>
</rss>

