<?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 How to add a flag on multiple records? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-flag-on-multiple-records/m-p/485039#M125977</link>
    <description>Hi, I have 1000 records in my file and i need to print a flag or variable or word 'Ind' (basically an indicator for me) on 100th position in every record.How i can achieve this?&lt;BR /&gt;&lt;BR /&gt;Thank you in advance!</description>
    <pubDate>Wed, 08 Aug 2018 07:41:11 GMT</pubDate>
    <dc:creator>SASInd</dc:creator>
    <dc:date>2018-08-08T07:41:11Z</dc:date>
    <item>
      <title>How to add a flag on multiple records?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-flag-on-multiple-records/m-p/485039#M125977</link>
      <description>Hi, I have 1000 records in my file and i need to print a flag or variable or word 'Ind' (basically an indicator for me) on 100th position in every record.How i can achieve this?&lt;BR /&gt;&lt;BR /&gt;Thank you in advance!</description>
      <pubDate>Wed, 08 Aug 2018 07:41:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-flag-on-multiple-records/m-p/485039#M125977</guid>
      <dc:creator>SASInd</dc:creator>
      <dc:date>2018-08-08T07:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a flag on multiple records?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-flag-on-multiple-records/m-p/485040#M125978</link>
      <description>&lt;P&gt;Post test data in the form of a datastep, we cannot see your computer!&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  if mod(_n_,100)=0 then flag=1;
run;&lt;/PRE&gt;
&lt;P&gt;Not tested.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 08:05:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-flag-on-multiple-records/m-p/485040#M125978</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-08T08:05:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a flag on multiple records?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-flag-on-multiple-records/m-p/485052#M125982</link>
      <description>Let me clear it out... I have an existing file like below&lt;BR /&gt;&lt;BR /&gt;column--&amp;gt; Name Age Gender&lt;BR /&gt;rows--&amp;gt;. Nesco 43 M&lt;BR /&gt;Greg 36 M&lt;BR /&gt;&lt;BR /&gt;I want to add an extra column named indicator so that my file should look like below&lt;BR /&gt;(Desired dataset)&lt;BR /&gt;&lt;BR /&gt;Nesco 43 M IND&lt;BR /&gt;Greg 36 M IND&lt;BR /&gt;&lt;BR /&gt;I want IND on fixed position for all the records.&lt;BR /&gt;&lt;BR /&gt;I hope now you are aware of my requirements</description>
      <pubDate>Wed, 08 Aug 2018 09:04:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-flag-on-multiple-records/m-p/485052#M125982</guid>
      <dc:creator>SASInd</dc:creator>
      <dc:date>2018-08-08T09:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a flag on multiple records?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-flag-on-multiple-records/m-p/485054#M125984</link>
      <description>&lt;P&gt;Please review the how to post a question guide below the Post button.&amp;nbsp; P&lt;U&gt;&lt;STRONG&gt;rovide test data in the form of a datastep and show what the output should look like.&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Hence the response remains the same:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  if mod(_n_,100)=0 then indicator="IND";
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Aug 2018 09:09:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-flag-on-multiple-records/m-p/485054#M125984</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-08T09:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a flag on multiple records?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-flag-on-multiple-records/m-p/485056#M125985</link>
      <description>Existing dataset:&lt;BR /&gt;Nesco 43 M&lt;BR /&gt;Greg 36 M&lt;BR /&gt;&lt;BR /&gt;Desired: (to add IND for all records in last column)&lt;BR /&gt;&lt;BR /&gt;Nesco 43 M IND&lt;BR /&gt;Greg 36 M IND&lt;BR /&gt;</description>
      <pubDate>Wed, 08 Aug 2018 09:16:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-flag-on-multiple-records/m-p/485056#M125985</guid>
      <dc:creator>SASInd</dc:creator>
      <dc:date>2018-08-08T09:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a flag on multiple records?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-flag-on-multiple-records/m-p/485057#M125986</link>
      <description>&lt;P&gt;I will try once more.&amp;nbsp; Please &lt;U&gt;&lt;STRONG&gt;provide test data in the form of a datastep which accurately shows your problem.&lt;/STRONG&gt;&lt;/U&gt;&amp;nbsp; What you have posted neither shows the data in a form that we can run, nor does it illustrate what to do or match the thread title.&amp;nbsp; Let me take my time to type some test data in for you and show you how to do it:&lt;/P&gt;
&lt;P&gt;Here is some test data which we can run and have something to work with:&lt;/P&gt;
&lt;PRE&gt;data have;
  input name $ age sex $;
datalines;
Nesco 43 M
Greg 36 M
Nesco 43 M
Greg 36 M
Nesco 43 M
Greg 36 M
Nesco 43 M
Greg 36 M
Nesco 43 M
Greg 36 M
;
run;&lt;/PRE&gt;
&lt;P&gt;Your thread title was how to flag X number of rows each time, to which I presented the code:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  if mod(_n_,3)=0 then indicator="IND";
run;&lt;/PRE&gt;
&lt;P&gt;If you put these two together you will fin that every 3rd row is flagged.&amp;nbsp; If this is not what you want, please describe thoroughly, providing test data in the form of a datastep and showing what you want out at the end.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 09:25:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-flag-on-multiple-records/m-p/485057#M125986</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-08T09:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a flag on multiple records?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-flag-on-multiple-records/m-p/485062#M125989</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will take a wild guess and assume that you want to create a new column at a predefined position in the dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a program that adds a column in sashelp.class in third position :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let pos=3;

proc sql;
	SELECT name
	INTO :before_pos separated by ','
	FROM dictionary.columns
	WHERE libname="SASHELP" AND memname="CLASS" AND varnum&amp;lt;&amp;amp;pos.;

	SELECT name
	INTO :after_pos separated by ','
	FROM dictionary.columns
	WHERE libname="SASHELP" AND memname="CLASS" AND varnum&amp;gt;=&amp;amp;pos.;

	CREATE TABLE WANT AS
	SELECT &amp;amp;before_pos., "IND" AS newvar, &amp;amp;after_pos.
	FROM sashelp.class;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Aug 2018 09:57:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-flag-on-multiple-records/m-p/485062#M125989</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-08-08T09:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a flag on multiple records?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-flag-on-multiple-records/m-p/485694#M126227</link>
      <description>&lt;P&gt;Achieved this by using FORMAT statement, able to print 'IND' on all records.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Aug 2018 10:03:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-a-flag-on-multiple-records/m-p/485694#M126227</guid>
      <dc:creator>SASInd</dc:creator>
      <dc:date>2018-08-10T10:03:10Z</dc:date>
    </item>
  </channel>
</rss>

