<?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: Input statement and line pointers in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Input-statement-and-line-pointers/m-p/621370#M77220</link>
    <description>&lt;P&gt;Your math on the number of lines seems off.&amp;nbsp; If you have 69 subjects and are reading 3 lines each time because of the #3 in the INPUT statement then your file needs to have 69*3= 187 lines and not 70 lines.&lt;/P&gt;
&lt;P&gt;Also why do you have the&amp;nbsp;@@ in the input statement?&amp;nbsp; What do you think that is trying to do?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 31 Jan 2020 05:29:21 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-01-31T05:29:21Z</dc:date>
    <item>
      <title>Input statement and line pointers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Input-statement-and-line-pointers/m-p/621369#M77219</link>
      <description>&lt;P&gt;Hi there!&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need help using the input statement with line pointers. When I run my code it seems to be leaving out the last subject in my dataset. We are using a txt file that has 70 subjects, each baseline, and post-intervention systolic blood pressure and weight values. I've created 69 rows that have sbp1 sbp2 wt1 and wt2 but the 70th subject seems to be missing. Any help would be appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CODE:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data HW2.hw2_saved;&lt;BR /&gt;infile 'C:\Users\rebec\Documents\BS 805\HW 2\HW2data.txt';&lt;BR /&gt;input #1 id 1-2 drug 3 sbp1 4-11 wt1 12-19 @@&lt;BR /&gt;#2 sbp2 4-11 wt2 12-19 @@&lt;BR /&gt;#3;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 05:22:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Input-statement-and-line-pointers/m-p/621369#M77219</guid>
      <dc:creator>RebeccaFaye</dc:creator>
      <dc:date>2020-01-31T05:22:02Z</dc:date>
    </item>
    <item>
      <title>Re: Input statement and line pointers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Input-statement-and-line-pointers/m-p/621370#M77220</link>
      <description>&lt;P&gt;Your math on the number of lines seems off.&amp;nbsp; If you have 69 subjects and are reading 3 lines each time because of the #3 in the INPUT statement then your file needs to have 69*3= 187 lines and not 70 lines.&lt;/P&gt;
&lt;P&gt;Also why do you have the&amp;nbsp;@@ in the input statement?&amp;nbsp; What do you think that is trying to do?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 05:29:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Input-statement-and-line-pointers/m-p/621370#M77220</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-01-31T05:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Input statement and line pointers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Input-statement-and-line-pointers/m-p/621373#M77221</link>
      <description>Thanks for the reply!&lt;BR /&gt;So I should have 70 subjects and 70 lines. Originally it had 140 lines (two for each subject) that had before and after sbp and weight. I'm trying to create a single row for each subject that has their baseline and post-intervention values for both sbp and weight. My code above seems to do this, but it just doesn't include my final subject (subject 70). I have 69 lines currently.&lt;BR /&gt;My understanding is that including "@@" , the pointer is not moved to the next row until there is no more data on the current row.</description>
      <pubDate>Fri, 31 Jan 2020 05:37:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Input-statement-and-line-pointers/m-p/621373#M77221</guid>
      <dc:creator>RebeccaFaye</dc:creator>
      <dc:date>2020-01-31T05:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: Input statement and line pointers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Input-statement-and-line-pointers/m-p/621441#M77223</link>
      <description>&lt;P&gt;The&amp;nbsp;@@ is for when you want to read from the same input line across iterations of the data step.&amp;nbsp; It does not make any sense to include that along with #nn command to read multiple lines at a time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is hard to tell from your description what you are doing, but it does sound like you are creating both the source text file and the program to read it. In that case you can design how to make the text file so that it is easy to read.&amp;nbsp; It is much easier to just read using list mode input statement (no column numbers or line pointers or cursor movement needed).&amp;nbsp; Just separate each value by a space, and if there are any missing values then type a period.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have repeated measures it might be easier to first read them into multiple observations.&amp;nbsp; Include a variable to indicate which timepoint (baseline, etc) this particular line of data represents.&amp;nbsp; You can then later use code to collapse the multiple observations for a subject into a single observation (if you need to).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;id visit date sbp dbp
1 baseline 2020/01/01 130 80
1 visit1 2020/01/05 135 85
2 baseline 2020/01/02 120 70
2 visit1 2020/01/04 . .&lt;/PRE&gt;
&lt;P&gt;Then to read that just do something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile 'myfile.txt' truncover firstobs=2;
  length id 8 visit $20 date sbp dbp 8;
  informat date yymmdd.;
  format date yymmdd10.;
  input id visit date sbp dbp;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 31 Jan 2020 15:10:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Input-statement-and-line-pointers/m-p/621441#M77223</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-01-31T15:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Input statement and line pointers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Input-statement-and-line-pointers/m-p/621448#M77224</link>
      <description>&lt;P&gt;Yeah, I think there is some miscommunication. I'm using this text file, which has 70 subjects. id is two columns wide, drug is 1 column wide, systolic is 8.4 and weight is 8.4. As you can see below, there are two values of sbp and wt for each subject. I'm trying to code it so that each subject has wt1, wt2, sbp 1, sbp2. The code I have in my question does this except for the last person (subject 70).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 0159.5681326.4100&lt;BR /&gt;1 0151.9329293.6876&lt;BR /&gt;2 0165.4389300.5860&lt;BR /&gt;2 0150.1996283.7959&lt;BR /&gt;3 0171.4973280.8458&lt;BR /&gt;3 0151.1499259.6988&lt;BR /&gt;4 0165.4576286.6310&lt;BR /&gt;4 0141.5292266.9363&lt;BR /&gt;5 0159.3755334.0693&lt;BR /&gt;5 0142.7102321.2893&lt;BR /&gt;6 0166.5624293.6374&lt;BR /&gt;6 0132.2037283.6696&lt;BR /&gt;7 0169.0907343.9146&lt;BR /&gt;7 0141.9615323.3449&lt;BR /&gt;8 0163.5120304.5511&lt;BR /&gt;8 0152.7732290.4707&lt;BR /&gt;9 0166.2658261.5245&lt;BR /&gt;9 0149.9705230.7379&lt;BR /&gt;100169.7736304.6510&lt;BR /&gt;100156.5528276.4445&lt;BR /&gt;110169.1036304.9042&lt;BR /&gt;110152.4192286.9123&lt;BR /&gt;120170.2859330.0572&lt;BR /&gt;120157.6702303.2747&lt;BR /&gt;130161.8547300.8148&lt;BR /&gt;130142.0642271.2437&lt;BR /&gt;140162.5493296.7611&lt;BR /&gt;140157.0179261.5387&lt;BR /&gt;150172.0278326.7975&lt;BR /&gt;150152.6488291.0720&lt;BR /&gt;160163.7540293.8948&lt;BR /&gt;160141.5212273.8226&lt;BR /&gt;170162.3134320.7320&lt;BR /&gt;170152.7504290.6913&lt;BR /&gt;180159.2775271.4223&lt;BR /&gt;180132.4960240.5594&lt;BR /&gt;190167.2594303.5583&lt;BR /&gt;190157.9902286.2519&lt;BR /&gt;200170.7307296.1399&lt;BR /&gt;200169.6361266.6828&lt;BR /&gt;210162.1713333.3012&lt;BR /&gt;210159.1371306.1875&lt;BR /&gt;220162.3564296.5399&lt;BR /&gt;220156.5967263.7341&lt;BR /&gt;230152.7704274.2653&lt;BR /&gt;230150.7561240.2737&lt;BR /&gt;240173.6744259.8890&lt;BR /&gt;240152.2780243.6764&lt;BR /&gt;250166.0481334.5533&lt;BR /&gt;250157.7285311.3080&lt;BR /&gt;260160.4775301.0612&lt;BR /&gt;260142.2116274.6485&lt;BR /&gt;270166.6046343.6577&lt;BR /&gt;270136.9973311.4744&lt;BR /&gt;280167.1002264.2434&lt;BR /&gt;280156.1143246.0969&lt;BR /&gt;290169.7849303.6547&lt;BR /&gt;290142.9119286.8014&lt;BR /&gt;300166.4623319.8161&lt;BR /&gt;300142.2134283.0690&lt;BR /&gt;310166.7051283.6408&lt;BR /&gt;310153.9403260.3265&lt;BR /&gt;320162.9531299.2106&lt;BR /&gt;320152.0810271.1111&lt;BR /&gt;330166.0902343.9262&lt;BR /&gt;330156.6240311.2010&lt;BR /&gt;340166.8419296.1088&lt;BR /&gt;340147.9662281.9905&lt;BR /&gt;350162.2641294.7835&lt;BR /&gt;350156.2530274.8917&lt;BR /&gt;361162.8022311.7296&lt;BR /&gt;361128.1358296.0558&lt;BR /&gt;371164.2243330.0920&lt;BR /&gt;371135.2787311.0607&lt;BR /&gt;381162.7693281.4027&lt;BR /&gt;381128.2672260.5932&lt;BR /&gt;391166.3379330.8296&lt;BR /&gt;391125.1558303.4728&lt;BR /&gt;401166.3239306.0454&lt;BR /&gt;401134.7172279.9112&lt;BR /&gt;411161.6041323.5907&lt;BR /&gt;411131.2541300.7474&lt;BR /&gt;421161.1067263.3350&lt;BR /&gt;421117.9163234.8007&lt;BR /&gt;431168.4125263.4290&lt;BR /&gt;431127.6125246.3988&lt;BR /&gt;441172.6001316.2644&lt;BR /&gt;441151.8035284.2606&lt;BR /&gt;451162.5576299.5690&lt;BR /&gt;451134.8550274.7804&lt;BR /&gt;461161.2977346.9898&lt;BR /&gt;461151.0471321.8582&lt;BR /&gt;471166.0088254.4366&lt;BR /&gt;471141.5393246.7747&lt;BR /&gt;481168.6832326.1522&lt;BR /&gt;481117.7683290.8532&lt;BR /&gt;491168.2362260.2254&lt;BR /&gt;491145.7905221.4781&lt;BR /&gt;501168.3405286.7257&lt;BR /&gt;501138.5886251.2554&lt;BR /&gt;511161.8059320.6078&lt;BR /&gt;511135.8792306.8499&lt;BR /&gt;521162.6127290.8030&lt;BR /&gt;521117.5527259.0737&lt;BR /&gt;531162.2732330.1135&lt;BR /&gt;531137.8331293.8114&lt;BR /&gt;541165.2403320.4246&lt;BR /&gt;541151.1756300.1615&lt;BR /&gt;551169.9302310.9467&lt;BR /&gt;551145.9754280.5010&lt;BR /&gt;561161.4438309.0915&lt;BR /&gt;561144.2470286.4452&lt;BR /&gt;571161.9408279.3986&lt;BR /&gt;571137.3766263.4707&lt;BR /&gt;581168.0201279.5537&lt;BR /&gt;581127.7842251.8098&lt;BR /&gt;591168.7627279.2311&lt;BR /&gt;591117.7954253.5130&lt;BR /&gt;601163.1336319.3774&lt;BR /&gt;601146.4423294.7547&lt;BR /&gt;611161.4851289.2949&lt;BR /&gt;611137.9098260.5804&lt;BR /&gt;621160.7298263.7955&lt;BR /&gt;621127.0981241.2411&lt;BR /&gt;631168.2941326.0085&lt;BR /&gt;631127.4673296.0329&lt;BR /&gt;641168.7856334.6582&lt;BR /&gt;641131.4100313.1587&lt;BR /&gt;651168.0534323.0171&lt;BR /&gt;651127.9741293.9351&lt;BR /&gt;661161.5909313.5617&lt;BR /&gt;661136.0589293.9657&lt;BR /&gt;671162.8097306.7994&lt;BR /&gt;671135.2356280.4640&lt;BR /&gt;681165.3995313.8665&lt;BR /&gt;681117.7197294.2240&lt;BR /&gt;691161.5544336.9836&lt;BR /&gt;691138.0893324.4739&lt;BR /&gt;701165.2871291.7631&lt;BR /&gt;701144.2423264.4141&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 15:25:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Input-statement-and-line-pointers/m-p/621448#M77224</guid>
      <dc:creator>RebeccaFaye</dc:creator>
      <dc:date>2020-01-31T15:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Input statement and line pointers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Input-statement-and-line-pointers/m-p/621454#M77225</link>
      <description>&lt;P&gt;Quick answer is your program was reading 3 lines at a time instead of the 2 lines that you data is using. So when it tried to read the last observation the data step stopped at the INPUT statement because it read past the end of the input file. So the last observation is never written to the output dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Personally I would just read the file line by line.&amp;nbsp; You can add a new variable to indicate which line is is for a particular id.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile txt ;
  input id $2. drug $1. sbp 8. dbp 8. ;
  if id ne lag(id) then rep=1;
  else rep+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;NOTE: 140 records were read from the infile TXT.
      The minimum record length was 19.
      The maximum record length was 19.
NOTE: The data set WORK.WANT has 140 observations and 5 variables.&lt;/PRE&gt;
&lt;P&gt;First few observations:&lt;/P&gt;
&lt;PRE&gt;Obs    id    drug      sbp        dbp      rep

  1    1      0      159.568    326.410     1
  2    1      0      151.933    293.688     2
  3    2      0      165.439    300.586     1
  4    2      0      150.200    283.796     2
  5    3      0      171.497    280.846     1
  6    3      0      151.150    259.699     2&lt;/PRE&gt;
&lt;P&gt;There is perhaps something wrong here as those pressure readings look wrong.&amp;nbsp; You said that they values were 8 positions wide.&amp;nbsp; But perhaps the values are something other than human blood pressure readings?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you did want to read two lines at once you could just use the / cursor movement to go to the next line.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  infile txt ;
  input id $2. drug $1. sbp 8. dbp 8. 
      / id2 $2. drug2 $1. spb2 8. dbp2 8.
  ;
  if id ne id2 or drug ne drug2 then do;
    put 'ERROR: There is a mismatch between the two lines. ' _n_= id= id2= drug= drug2= ;
    delete;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;NOTE: 140 records were read from the infile TXT.
      The minimum record length was 19.
      The maximum record length was 19.
NOTE: The data set WORK.WANT has 70 observations and 8 variables.&lt;/PRE&gt;
&lt;P&gt;Values:&lt;/P&gt;
&lt;PRE&gt;Obs    id    drug      sbp        dbp      id2    drug2      spb2       dbp2

  1    1      0      159.568    326.410     1       0      151.933    293.688
  2    2      0      165.439    300.586     2       0      150.200    283.796
  3    3      0      171.497    280.846     3       0      151.150    259.699
  4    4      0      165.458    286.631     4       0      141.529    266.936
  5    5      0      159.376    334.069     5       0      142.710    321.289
  6    6      0      166.562    293.637     6       0      132.204    283.670&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 15:47:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Input-statement-and-line-pointers/m-p/621454#M77225</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-01-31T15:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: Input statement and line pointers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Input-statement-and-line-pointers/m-p/621491#M77230</link>
      <description>&lt;P&gt;Or: I use data lines but the input statement should work for your&amp;nbsp;file as well. The / says "read from next line" in effect.&lt;/P&gt;
&lt;PRE&gt;data example;
input  id 1-2 drug 3 sbp1 4-11 wt1 12-19 
     / sbp2 4-11 wt2 12-19
;
datalines;
1 0159.5681326.4100
1 0151.9329293.6876
2 0165.4389300.5860
2 0150.1996283.7959
3 0171.4973280.8458
3 0151.1499259.6988
4 0165.4576286.6310
4 0141.5292266.9363
5 0159.3755334.0693
5 0142.7102321.2893
6 0166.5624293.6374
6 0132.2037283.6696
7 0169.0907343.9146
7 0141.9615323.3449
8 0163.5120304.5511
8 0152.7732290.4707
9 0166.2658261.5245
9 0149.9705230.7379
;&lt;/PRE&gt;
&lt;P&gt;As and aside, it is a good idea to post examples of text files into a code box opened using the forum's {I} icon as message window will often remove white space, which could change the column positions if there are multiple adjacent spaces.&lt;/P&gt;
&lt;P&gt;And if there are tab characters you need to tell us as they are not visible and it may not be possible to tell from the appearance of the text.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 16:59:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Input-statement-and-line-pointers/m-p/621491#M77230</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-01-31T16:59:22Z</dc:date>
    </item>
  </channel>
</rss>

