<?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 Trailing @ in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trailing/m-p/519510#M140710</link>
    <description>&lt;P&gt;I am working on an exercise in which I believe I need to use triailing @.&lt;/P&gt;&lt;P&gt;I am given this data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;M100&lt;STRONG&gt;1&lt;/STRONG&gt;01 Armann&lt;BR /&gt;10 10 10 10 8 9&lt;BR /&gt;13 15 10&lt;BR /&gt;M100&lt;STRONG&gt;1&lt;/STRONG&gt;02 Ellery&lt;BR /&gt;8 10 7 6 10 1&lt;BR /&gt;7 12 15&lt;BR /&gt;M100&lt;STRONG&gt;1&lt;/STRONG&gt;03 Anna&lt;BR /&gt;7 5 10 4 10 10&lt;BR /&gt;12 9 11&lt;/P&gt;&lt;P&gt;M100&lt;STRONG&gt;3&lt;/STRONG&gt;02 Duc&lt;BR /&gt;14 12 10 12&lt;BR /&gt;9 10 10 8 10 10 10&lt;BR /&gt;M100&lt;STRONG&gt;3&lt;/STRONG&gt;03 Woo&lt;BR /&gt;14 15 12 9&lt;BR /&gt;8 7 9 10 5 9 10&lt;BR /&gt;M100&lt;STRONG&gt;3&lt;/STRONG&gt;04 Olson&lt;BR /&gt;10 10 12 11&lt;BR /&gt;5 10 7 9 8 10 10&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The bolded number is called the course section.&lt;/P&gt;&lt;P&gt;If course section = 1 then print quizgrades hwgrades&lt;/P&gt;&lt;P&gt;If course section = 3 then print hw grades quizgrades&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to print out two datasets, one for section 1 and one for section 3.&lt;/P&gt;&lt;P&gt;I am having an issue with my trailing @. I am not sure what I am doing wrong or how I can fix this.&lt;/P&gt;&lt;P&gt;(using datalines for simplicity for now, will change later)&lt;/P&gt;&lt;P&gt;Here's my code and the output&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; *libname datain '\\Client\I$\SAS2018\Data';

data hw7_a;
*infile '\\Client\I$\SAS2018\Data\studentinfo.txt';
input Name $1-4 Section 5 @ Student_Chars 7;
if section= 1 then do;
        input Q1-Q6 2 HW1-HW3 2;
        output;
        end;
if section= 3 then do;
        input HW1-HW4 2 Q1-Q7 2;
        output;
        end;
datalines;

M100101 Armann
10 10 10 10 8 9
13 15 10
M100102 Ellery
8 10 7 6 10 1
7 12 15
M100103 Anna
7 5 10 4 10 10
12 9 11

M100302 Duc
14 12 10 12
9 10 10 8 10 10 10
M100303 Woo
14 15 12 9
8 7 9 10 5 9 10
M100304 Olson
10 10 12 11
5 10 7 9 8 10 10
;
run;

proc print;
format Student_Chars z2.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2018-12-07 at 10.43.40 AM.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/25463i3E44B094165019B4/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2018-12-07 at 10.43.40 AM.png" alt="Screen Shot 2018-12-07 at 10.43.40 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Dec 2018 18:47:38 GMT</pubDate>
    <dc:creator>clancaster</dc:creator>
    <dc:date>2018-12-07T18:47:38Z</dc:date>
    <item>
      <title>Trailing @</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trailing/m-p/519510#M140710</link>
      <description>&lt;P&gt;I am working on an exercise in which I believe I need to use triailing @.&lt;/P&gt;&lt;P&gt;I am given this data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;M100&lt;STRONG&gt;1&lt;/STRONG&gt;01 Armann&lt;BR /&gt;10 10 10 10 8 9&lt;BR /&gt;13 15 10&lt;BR /&gt;M100&lt;STRONG&gt;1&lt;/STRONG&gt;02 Ellery&lt;BR /&gt;8 10 7 6 10 1&lt;BR /&gt;7 12 15&lt;BR /&gt;M100&lt;STRONG&gt;1&lt;/STRONG&gt;03 Anna&lt;BR /&gt;7 5 10 4 10 10&lt;BR /&gt;12 9 11&lt;/P&gt;&lt;P&gt;M100&lt;STRONG&gt;3&lt;/STRONG&gt;02 Duc&lt;BR /&gt;14 12 10 12&lt;BR /&gt;9 10 10 8 10 10 10&lt;BR /&gt;M100&lt;STRONG&gt;3&lt;/STRONG&gt;03 Woo&lt;BR /&gt;14 15 12 9&lt;BR /&gt;8 7 9 10 5 9 10&lt;BR /&gt;M100&lt;STRONG&gt;3&lt;/STRONG&gt;04 Olson&lt;BR /&gt;10 10 12 11&lt;BR /&gt;5 10 7 9 8 10 10&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The bolded number is called the course section.&lt;/P&gt;&lt;P&gt;If course section = 1 then print quizgrades hwgrades&lt;/P&gt;&lt;P&gt;If course section = 3 then print hw grades quizgrades&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to print out two datasets, one for section 1 and one for section 3.&lt;/P&gt;&lt;P&gt;I am having an issue with my trailing @. I am not sure what I am doing wrong or how I can fix this.&lt;/P&gt;&lt;P&gt;(using datalines for simplicity for now, will change later)&lt;/P&gt;&lt;P&gt;Here's my code and the output&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; *libname datain '\\Client\I$\SAS2018\Data';

data hw7_a;
*infile '\\Client\I$\SAS2018\Data\studentinfo.txt';
input Name $1-4 Section 5 @ Student_Chars 7;
if section= 1 then do;
        input Q1-Q6 2 HW1-HW3 2;
        output;
        end;
if section= 3 then do;
        input HW1-HW4 2 Q1-Q7 2;
        output;
        end;
datalines;

M100101 Armann
10 10 10 10 8 9
13 15 10
M100102 Ellery
8 10 7 6 10 1
7 12 15
M100103 Anna
7 5 10 4 10 10
12 9 11

M100302 Duc
14 12 10 12
9 10 10 8 10 10 10
M100303 Woo
14 15 12 9
8 7 9 10 5 9 10
M100304 Olson
10 10 12 11
5 10 7 9 8 10 10
;
run;

proc print;
format Student_Chars z2.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2018-12-07 at 10.43.40 AM.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/25463i3E44B094165019B4/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2018-12-07 at 10.43.40 AM.png" alt="Screen Shot 2018-12-07 at 10.43.40 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 18:47:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trailing/m-p/519510#M140710</guid>
      <dc:creator>clancaster</dc:creator>
      <dc:date>2018-12-07T18:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: Trailing @</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trailing/m-p/519619#M140770</link>
      <description>&lt;P&gt;Actually you do not want to use the @ to hold position. You want to read the first of the three lines. Then depending on result for the first line read two additional lines. Your @ was not in the correct place to hold the line for reading, it should be the last character on the input statement. The @ may also be used to indicate a text position ( @'M100' for example) to read or a column number (@27) to move the input pointer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please see:&lt;/P&gt;
&lt;PRE&gt;data hw7_a;
*infile '\\Client\I$\SAS2018\Data\studentinfo.txt';
input Name $1-4 Section 5 Student $ ;
if section= 1 then do;
        input  Q1-Q6 
             / HW1-HW3;
        output;
        end;
if section= 3 then do;
        input HW1-HW4 
             / Q1-Q7 ;
        output;
        end;
datalines;
M100101 Armann
10 10 10 10 8 9
13 15 10
M100102 Ellery
8 10 7 6 10 1
7 12 15
M100103 Anna
7 5 10 4 10 10
12 9 11
M100302 Duc
14 12 10 12
9 10 10 8 10 10 10
M100303 Woo
14 15 12 9
8 7 9 10 5 9 10
M100304 Olson
10 10 12 11
5 10 7 9 8 10 10
;
run;
&lt;/PRE&gt;
&lt;P&gt;The / in the input statement says to continue reading on the next line. Datalines with blank lines don't always work the same as a text file so I removed them from the example. If your data file actually has that blank after every group of three lines add another / to the section input statements after the last variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With spaces between values you can use LIST input without trying to force a position or number of columns for a numeric value.&lt;/P&gt;
&lt;P&gt;You also did not provide anything where the code knew that the Student was to be a character variable. The $ does that with a default length of 8 characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know what you mean exactly by "print two datasets" but you can get different output for each section using the example code since the records are in Section order &amp;nbsp;with:&lt;/P&gt;
&lt;PRE&gt;proc print  data=hw7_a;
 by section;
run;&lt;/PRE&gt;
&lt;P&gt;If your data actually has Section values scattered then you would sort the data before printing with proc sort.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are different ways to get print output such as different title statements and where statement in the Proc print to restrict a specific print to selected values of the section variable. I can't tell if you actually want the order of variables the same or different in the print results.&lt;/P&gt;
&lt;P&gt;Or a custom format for the section variable could show text in the By&amp;nbsp;line (Section &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt; of&lt;/P&gt;</description>
      <pubDate>Sat, 08 Dec 2018 00:46:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trailing/m-p/519619#M140770</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-12-08T00:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: Trailing @</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trailing/m-p/519684#M140806</link>
      <description>&lt;P&gt;This was incredibly insightful. Thank you.&lt;/P&gt;</description>
      <pubDate>Sat, 08 Dec 2018 20:47:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trailing/m-p/519684#M140806</guid>
      <dc:creator>clancaster</dc:creator>
      <dc:date>2018-12-08T20:47:00Z</dc:date>
    </item>
  </channel>
</rss>

