<?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: How to create a dataset ? in Programming 1 and 2</title>
    <link>https://communities.sas.com/t5/Programming-1-and-2/How-to-create-a-dataset/m-p/923404#M1476</link>
    <description>Hi:&lt;BR /&gt;  In the Programming 2 class, we have a SAS dataset called weather_japan.sas7bdat, so if you are working in that class, and with the demo program p203d03.sas, you would not need to create weather_japan because it already exists.&lt;BR /&gt;  Can you clarify where in the Programming 2 class you are working and provide the title of the practice or demo you're trying to do?&lt;BR /&gt;Thanks,&lt;BR /&gt;Cynthia</description>
    <pubDate>Mon, 08 Apr 2024 14:13:29 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2024-04-08T14:13:29Z</dc:date>
    <item>
      <title>How to create a dataset ?</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/How-to-create-a-dataset/m-p/923266#M1471</link>
      <description>&lt;P&gt;As i have created a data set to use numeric function like "INTCK" and "INTNX" but I don't know why my data is getting truncated although i have use length keyword still the data get truncated.&lt;/P&gt;&lt;P&gt;Can anyone please correct me where I am going wrong. This would be really helpful if anyone can explain so that the same mistake wont repeat again. Thanks in advance.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Priya&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Kindly find below screenshot for coding, Log and Output Result reference.&lt;/P&gt;&lt;P&gt;A. Coding section :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PriyaB_1-1712378330552.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95262i8FC622EBBE877EB4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PriyaB_1-1712378330552.png" alt="PriyaB_1-1712378330552.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;B. Log Section :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PriyaB_2-1712378355800.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95263iA5923B7B1C8C9945/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PriyaB_2-1712378355800.png" alt="PriyaB_2-1712378355800.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;C. Output Result:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PriyaB_3-1712378384345.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95264iA99E8568E819B539/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PriyaB_3-1712378384345.png" alt="PriyaB_3-1712378384345.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Apr 2024 04:41:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/How-to-create-a-dataset/m-p/923266#M1471</guid>
      <dc:creator>PriyaB</dc:creator>
      <dc:date>2024-04-06T04:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a dataset ?</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/How-to-create-a-dataset/m-p/923268#M1472</link>
      <description>What kind of output would you like to see ?</description>
      <pubDate>Sat, 06 Apr 2024 05:22:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/How-to-create-a-dataset/m-p/923268#M1472</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-04-06T05:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a dataset ?</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/How-to-create-a-dataset/m-p/923271#M1473</link>
      <description>&lt;P&gt;We can help you best if you share your code with the data not as a screenshot but as text that we then can copy/paste as a starting point.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the running man icon to post such code and data.&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1712381785750.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95265iF9461691221CACB8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1712381785750.png" alt="Patrick_0-1712381785750.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At least one of the issues with your current code:&lt;/P&gt;
&lt;P&gt;You define a length for variable location which instructs SAS how to create the variable BUT it doesn't instruct SAS how to read source data.&amp;nbsp;You need to define/use an INFORMAT for this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your input statement you're using INPUT ... location $&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With this syntax SAS will only read the first 8 characters. Try and use INPUT ... location :$20. instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Apr 2024 05:39:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/How-to-create-a-dataset/m-p/923271#M1473</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-04-06T05:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a dataset ?</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/How-to-create-a-dataset/m-p/923286#M1474</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/458884"&gt;@PriyaB&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition to the insufficient length specifications, at least for variable STATION, mentioned by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;(I disagree with his comment about "location $", though) there is the issue of embedded blanks in the character values -- assuming that the "JA &lt;EM&gt;digit sequence&lt;/EM&gt;" part of your data lines is the intended value of STATION and the rest is for LOCATION.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It &lt;EM&gt;looks like&lt;/EM&gt; the two values on each line are separated by two blanks (green rectangles below).&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PriyaBs_datalines.png" style="width: 285px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/95270i6678EA6ECE8503E2/image-size/large?v=v2&amp;amp;px=999" role="button" title="PriyaBs_datalines.png" alt="PriyaBs_datalines.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;But from a screenshot we can't tell for sure if a "blank" is an ordinary space character (ASCII code 32). Strangely enough, the two "blanks" (?) indicated by the red arrows above do not occur in the screenshot of your output -- which suggests that you created that output from slightly different data lines.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Character variable STATION is created with the default length of 8 bytes, but presumably ought to accommodate up to 16 characters. You increased the length of LOCATION to 20 bytes, but this is still insufficient for the 22-character string "&lt;FONT face="courier new,courier"&gt;MIYAKE-JIMA, TOKYO, JA&lt;/FONT&gt;" (or do you want to omit the "JA" at the end because it is redundant in a dataset named&amp;nbsp;&lt;FONT face="courier new,courier"&gt;weather_&lt;EM&gt;japan&lt;/EM&gt;&lt;/FONT&gt;?).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, you could use&lt;/P&gt;
&lt;PRE&gt;length &lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;station $16&lt;/STRONG&gt;&lt;/FONT&gt; location $&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;22&lt;/STRONG&gt;&lt;/FONT&gt;;
input station &lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;&amp;amp;&lt;/STRONG&gt;&lt;/FONT&gt; location &lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;&amp;amp;&lt;/STRONG&gt;&lt;/FONT&gt;;&lt;/PRE&gt;
&lt;P&gt;The ampersand signs allow for the embedded single blanks in the values (see documentation &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n0lrz3gb7m9e4rn137op544ddg0v.htm" target="_blank" rel="noopener"&gt;INPUT: List&lt;/A&gt;), given the double-blank column separators.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively, you could integrate the length definitions into the INPUT statement by adding informat specifications and omit the LENGTH statement:&lt;/P&gt;
&lt;PRE&gt;input station &amp;amp;&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;:$16.&lt;/STRONG&gt;&lt;/FONT&gt; location &amp;amp;&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;:$22.&lt;/STRONG&gt;&lt;/FONT&gt;;&lt;/PRE&gt;
&lt;P&gt;(see again the&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n0lrz3gb7m9e4rn137op544ddg0v.htm" target="_blank" rel="noopener"&gt;INPUT: List&lt;/A&gt;&amp;nbsp;documentation; this is &lt;EM&gt;modified list input&lt;/EM&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or, similarly, with a more generous, common length definition for both variables:&lt;/P&gt;
&lt;PRE&gt;input &lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/FONT&gt;station location&lt;STRONG&gt;&lt;FONT color="#3366FF"&gt;) (&lt;/FONT&gt;&lt;/STRONG&gt;&amp;amp;:$&lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;25&lt;/STRONG&gt;&lt;/FONT&gt;.&lt;STRONG&gt;&lt;FONT color="#3366FF"&gt;)&lt;/FONT&gt;&lt;/STRONG&gt;;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Apr 2024 10:24:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/How-to-create-a-dataset/m-p/923286#M1474</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-04-06T10:24:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a dataset ?</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/How-to-create-a-dataset/m-p/923287#M1475</link>
      <description>&lt;P&gt;As others have mentioned, the problem lies with your instructions to read in the data.&amp;nbsp; While &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;has shown some of the many choices you have available, the simplest (yet intuitive) way to read the data would be like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data weather_japan;
input station $ 1-17 location $ 18-40;
datalilnes;
... same datalines that you posted ...
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You would have to do the work of telling SAS where to find the fields you are reading.&amp;nbsp; SAS will pull the data from the columns you specify.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note, this style of inputting the data will left-hand justify whatever it finds so it won't matter whether LOCATION begins in column 18 or column 19.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, this can't be your final data set.&amp;nbsp; There are no variables suitable for practicing the INTNX or INTCK functions&lt;/P&gt;</description>
      <pubDate>Sat, 06 Apr 2024 10:37:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/How-to-create-a-dataset/m-p/923287#M1475</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2024-04-06T10:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a dataset ?</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/How-to-create-a-dataset/m-p/923404#M1476</link>
      <description>Hi:&lt;BR /&gt;  In the Programming 2 class, we have a SAS dataset called weather_japan.sas7bdat, so if you are working in that class, and with the demo program p203d03.sas, you would not need to create weather_japan because it already exists.&lt;BR /&gt;  Can you clarify where in the Programming 2 class you are working and provide the title of the practice or demo you're trying to do?&lt;BR /&gt;Thanks,&lt;BR /&gt;Cynthia</description>
      <pubDate>Mon, 08 Apr 2024 14:13:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/How-to-create-a-dataset/m-p/923404#M1476</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2024-04-08T14:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a dataset ?</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/How-to-create-a-dataset/m-p/923415#M1477</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;You define a length for variable location which instructs SAS how to create the variable BUT it doesn't instruct SAS how to read source data.&amp;nbsp;You need to define/use an INFORMAT for this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your input statement you're using INPUT ... location $&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With this syntax SAS will only read the first 8 characters. Try and use INPUT ... location :$20. instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your description of the impact of adding $ after LOCATION in the INPUT statement is wrong.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A bare $ in an INPUT function merely gives SAS a hint that if the variable was not previously defined then to define it as character.&amp;nbsp; And with no other information about what length to set for the variable it will use $8.&amp;nbsp; But in this case the variable is already defined to have length $20.&amp;nbsp; So the $ in the INPUT statement does nothing at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The INPUT statement will read the next "word" from the line based on the current delimiter (the default is the space character).&amp;nbsp; Leading spaces will be ignored and the first 20 bytes will be stored into LOCATION.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2024 15:02:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/How-to-create-a-dataset/m-p/923415#M1477</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-04-08T15:02:15Z</dc:date>
    </item>
  </channel>
</rss>

