<?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 Creating a data set with multiple identical observations using the datalines statement in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-data-set-with-multiple-identical-observations-using/m-p/104908#M29296</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to create a date set by entering information using the datelines statement in a data step.&amp;nbsp; For instance, I have multiple observations with the same value. I was wondering if there was a shorthand way of entering these values for multiple observations without having to type them one by one. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data students;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input Age;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and so on...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a function or an operator that I can use to generate repeated values.&amp;nbsp; I know certain programming languages you can take a value and add the product sign&amp;nbsp; (*) and a number to do this sort of operation.&amp;nbsp; Is there something similar in SAS?&amp;nbsp; Thanks for your response and help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Jun 2013 00:30:59 GMT</pubDate>
    <dc:creator>Simon80</dc:creator>
    <dc:date>2013-06-13T00:30:59Z</dc:date>
    <item>
      <title>Creating a data set with multiple identical observations using the datalines statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-data-set-with-multiple-identical-observations-using/m-p/104908#M29296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to create a date set by entering information using the datelines statement in a data step.&amp;nbsp; For instance, I have multiple observations with the same value. I was wondering if there was a shorthand way of entering these values for multiple observations without having to type them one by one. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data students;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input Age;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and so on...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a function or an operator that I can use to generate repeated values.&amp;nbsp; I know certain programming languages you can take a value and add the product sign&amp;nbsp; (*) and a number to do this sort of operation.&amp;nbsp; Is there something similar in SAS?&amp;nbsp; Thanks for your response and help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jun 2013 00:30:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-data-set-with-multiple-identical-observations-using/m-p/104908#M29296</guid>
      <dc:creator>Simon80</dc:creator>
      <dc:date>2013-06-13T00:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set with multiple identical observations using the datalines statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-data-set-with-multiple-identical-observations-using/m-p/104909#M29297</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Requires a little programming :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data students(keep=age);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;infile datalines missover;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;input Age repeat;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;do i = 1 to coalesce(repeat, 1);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;datalines;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;20 4&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;10&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;15 2&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;55&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc print; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But don't forget that most data analysis procedures allow a FREQ statement that names a variable containing observation frequencies. Thus, you could use :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data students(keep=age repeat);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;infile datalines missover;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;input Age repeat;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;repeat = coalesce(repeat,1);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;datalines;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;20 4&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;10&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;15 2&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;55&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc univariate data=students; var age; freq repeat; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jun 2013 00:57:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-data-set-with-multiple-identical-observations-using/m-p/104909#M29297</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-06-13T00:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set with multiple identical observations using the datalines statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-data-set-with-multiple-identical-observations-using/m-p/104910#M29298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PGStats, thank you for your quick response!&amp;nbsp; I tried the second method and it works beautifully!&amp;nbsp; I also tried a very minimal data step, shown below, based on yours that also seems to work. Would you mind explaining a few things to me as I'm relatively new to SAS. In your code, you have the infile statement (&lt;STRONG&gt;infile datalines missover)&lt;/STRONG&gt;.&amp;nbsp; What is this for? Why did you use the coalesce function? I know it returns the first non-missing value but I don't understand what its function is in your data step.&amp;nbsp; Thanks for your help! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My simplified code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data students(keep=age repeat);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;input Age repeat;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;datalines;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;20 4&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;10&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;15 2&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;55&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc univariate data=students; var age; freq repeat; run;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jun 2013 03:20:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-data-set-with-multiple-identical-observations-using/m-p/104910#M29298</guid>
      <dc:creator>Simon80</dc:creator>
      <dc:date>2013-06-13T03:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set with multiple identical observations using the datalines statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-data-set-with-multiple-identical-observations-using/m-p/104911#M29299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When you run that code, you get the following error messages:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal,monaco;"&gt;NOTE: LOST CARD.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal,monaco;"&gt;RULE:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ----+----1----+----2----+----3----+----4----+----5----+----6----+----7---&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal,monaco;"&gt;10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal,monaco;"&gt;Age=55 repeat=. _ERROR_=1 _N_=3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal,monaco;"&gt;NOTE: SAS went to a new line when INPUT statement reached past the end of a line.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: terminal,monaco;"&gt;NOTE: The data set WORK.STUDENTS has 2 observations and 2 variables.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; The reason for this is that the default behaviour when SAS reads data is to go to the next line to read the remaining input variables. The first statement&amp;nbsp; (&lt;STRONG&gt;infile datalines missover)&lt;/STRONG&gt; tells SAS to set the remaining variables to missing when the end of line is reached. The use of coalesce function says that when repeat is missing, take it as meaning 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jun 2013 14:18:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-data-set-with-multiple-identical-observations-using/m-p/104911#M29299</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-06-13T14:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set with multiple identical observations using the datalines statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-data-set-with-multiple-identical-observations-using/m-p/104912#M29300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Depending on the analysis you're going to do, I suggest investigating in adding the count variable to every value, not creating multiple records and use the WEIGHT option in analysis with the count as the weight variable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jun 2013 15:14:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-data-set-with-multiple-identical-observations-using/m-p/104912#M29300</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-06-13T15:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set with multiple identical observations using the datalines statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-data-set-with-multiple-identical-observations-using/m-p/104913#M29301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks again PGStats! &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&amp;nbsp; I think I understand now.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jun 2013 15:19:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-data-set-with-multiple-identical-observations-using/m-p/104913#M29301</guid>
      <dc:creator>Simon80</dc:creator>
      <dc:date>2013-06-13T15:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set with multiple identical observations using the datalines statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-data-set-with-multiple-identical-observations-using/m-p/104914#M29302</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ballardw, thanks for your input! I haven't seen the WEIGHT option before. Can you please tell me what it does? Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jun 2013 15:24:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-data-set-with-multiple-identical-observations-using/m-p/104914#M29302</guid>
      <dc:creator>Simon80</dc:creator>
      <dc:date>2013-06-13T15:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set with multiple identical observations using the datalines statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-data-set-with-multiple-identical-observations-using/m-p/104915#M29303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually more properly with your data the FREQ option might be better which is available in many procs, says to use the count variable and treat that record as representing N records.&lt;/P&gt;&lt;P&gt;For example with proc univariate add a statement&lt;/P&gt;&lt;P&gt;Freq countvariablename;&lt;/P&gt;&lt;P&gt;Weights are similar but need not be integers and affect calculations of some statistics a bit differently.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jun 2013 15:40:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-data-set-with-multiple-identical-observations-using/m-p/104915#M29303</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-06-13T15:40:14Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a data set with multiple identical observations using the datalines statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-a-data-set-with-multiple-identical-observations-using/m-p/104916#M29304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks ballardw! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Jun 2013 16:50:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-a-data-set-with-multiple-identical-observations-using/m-p/104916#M29304</guid>
      <dc:creator>Simon80</dc:creator>
      <dc:date>2013-06-14T16:50:58Z</dc:date>
    </item>
  </channel>
</rss>

