<?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: Data managing in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-managing/m-p/355707#M83314</link>
    <description>&lt;P&gt;Thank you so much dear Draycut.&lt;/P&gt;&lt;P&gt;I used&lt;/P&gt;&lt;P&gt;&amp;amp; missing(X2) &amp;amp; missing(X3)&amp;nbsp;&amp;amp; .... I worked perfectly.&lt;/P&gt;&lt;P&gt;Thanks again and I appreciate your help very much.&lt;/P&gt;</description>
    <pubDate>Wed, 03 May 2017 18:20:00 GMT</pubDate>
    <dc:creator>sijansap</dc:creator>
    <dc:date>2017-05-03T18:20:00Z</dc:date>
    <item>
      <title>Data managing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-managing/m-p/355649#M83290</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Dear SAS community,&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;I got the following problem on data manipulation. I would appreciate very much for you kind help.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Thank you.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; HAVE;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; X1 X2 X3 X4; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;DX1-X20=Substr(X1-X20, &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;, &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;3&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;); &lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;/*All input values are charecters, and I have over 300k rows with 20&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; columns, there are no data after certain column in each row*/&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;cards&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;360&amp;nbsp; 361&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 290&amp;nbsp; 3321&lt;/P&gt;&lt;P&gt;360&lt;/P&gt;&lt;P&gt;400&amp;nbsp; 4021&amp;nbsp;&amp;nbsp; 405&amp;nbsp;&lt;/P&gt;&lt;P&gt;225&lt;/P&gt;&lt;P&gt;112&amp;nbsp; 227&amp;nbsp;&amp;nbsp;&amp;nbsp; 865&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;342&lt;/P&gt;&lt;P&gt;360 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 443&amp;nbsp;&amp;nbsp; 361&lt;/P&gt;&lt;P&gt;360&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;870&lt;/P&gt;&lt;P&gt;360&lt;/P&gt;&lt;P&gt;360&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;I WANT:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;if 360 is in first column, and there are no other input in any other column in the same row then count is one&amp;nbsp;otherwise zero. So in the above data, for 360 I want count=1 from second row and count=1 each from last two rows rest zeros. Similarly for 225 I should get count=1 only from 4th row, etc.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;I would appreciate very for your kindly help.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2017 15:39:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-managing/m-p/355649#M83290</guid>
      <dc:creator>sijansap</dc:creator>
      <dc:date>2017-05-03T15:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: Data managing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-managing/m-p/355660#M83294</link>
      <description>&lt;P&gt;You say that X1-X4 are character variables, but you have defined them as numeric?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you want something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;&lt;BR /&gt;input X1 $ X2 $ X3 $ X4 $;&lt;BR /&gt;infile cards missover;&lt;BR /&gt;cards;&lt;BR /&gt;360 361 290 3321&lt;BR /&gt;360&lt;BR /&gt;400 4021 405 &lt;BR /&gt;225&lt;BR /&gt;112 227 865 342&lt;BR /&gt;360 443 361&lt;BR /&gt;360 870&lt;BR /&gt;360&lt;BR /&gt;360&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt; set have;&lt;BR /&gt; if cmiss(X2,X3,X4)=3 then count = 1;&lt;BR /&gt; else count = 0;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 May 2017 17:12:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-managing/m-p/355660#M83294</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-05-03T17:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: Data managing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-managing/m-p/355703#M83312</link>
      <description>&lt;P&gt;YOu want the count of non-blank character variables.&amp;nbsp; But your data sample is numeric.&amp;nbsp; In that case, you can use the N function (number of non-missing values).&amp;nbsp; The "of x:"&amp;nbsp; argument implies a list of all variables whose name begins with x.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
infile datalines missover;
input X1 X2 X3 X4; 
cards;
360  361     290  3321
360
400  4021   405 
225
112  227    865          342
360            443   361
360            870
360
360
run;

data want;
  set have;
  nx=n(of x:);
  put _n_= nx=;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now if the vars really are character,&amp;nbsp;then you can concatenate them with comma separation (catx function), and then count the number of comma-separated "words" (countw) in the concatenation:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
infile datalines missover;
input (X1 X2 X3 X4) (:$4.);
cards;
360  361     290  3321
360
400  4021   405 
225
112  227    865          342
360            443   361
360            870
360
360
run;

data want;
  set have;
  nx=countw(catx(',',of x:));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2017 18:08:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-managing/m-p/355703#M83312</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-05-03T18:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: Data managing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-managing/m-p/355707#M83314</link>
      <description>&lt;P&gt;Thank you so much dear Draycut.&lt;/P&gt;&lt;P&gt;I used&lt;/P&gt;&lt;P&gt;&amp;amp; missing(X2) &amp;amp; missing(X3)&amp;nbsp;&amp;amp; .... I worked perfectly.&lt;/P&gt;&lt;P&gt;Thanks again and I appreciate your help very much.&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2017 18:20:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-managing/m-p/355707#M83314</guid>
      <dc:creator>sijansap</dc:creator>
      <dc:date>2017-05-03T18:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: Data managing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-managing/m-p/355777#M83335</link>
      <description>&lt;P&gt;Anytime, glad to help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2017 20:38:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-managing/m-p/355777#M83335</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-05-03T20:38:08Z</dc:date>
    </item>
    <item>
      <title>Re: Data managing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-managing/m-p/355805#M83347</link>
      <description>&lt;P&gt;&lt;FONT color="#0000ff" face="SAS Monospace" size="2"&gt;Please note that where/how you paste code in this forum makes a difference.&lt;/FONT&gt;&lt;FONT color="#0000ff" face="SAS Monospace" size="2"&gt;For example pasting into the main message window as you did resulted in this:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000" face="SAS Monospace" size="2"&gt;Data HAVE&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="SAS Monospace" size="2"&gt;input&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt; X1 X2 X3 X4; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="SAS Monospace" size="2"&gt;cards&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;360 361 290 3321&lt;/P&gt;
&lt;P&gt;360&lt;/P&gt;
&lt;P&gt;400 4021 405&lt;/P&gt;
&lt;P&gt;225&lt;/P&gt;
&lt;P&gt;112 227 865 342&lt;/P&gt;
&lt;P&gt;360 443 361&lt;/P&gt;
&lt;P&gt;360 870&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the SAME source from the SAS editor pasted into a code box using the forum {i} menu icon shows:&lt;/P&gt;
&lt;PRE&gt;data HAVE;
input X1 X2 X3 X4; 
cards;
360  361     290  3321
     360
400  4021   405 
225
112  227    865   342
360         443   361
360         870
;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why do I mention this? Your request mentions "when 360 is in the first column". The code in the code box for the second row of data would tend to imply the 360 is in the second "column" and the other paste would have it in the first.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also your data step as pasted may well have issues other than the numeric / character confusion pointed out. Reading the last two rows will have 443 and 870 in the x2 variable. Was that the intent?&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2017 22:33:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-managing/m-p/355805#M83347</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-05-03T22:33:39Z</dc:date>
    </item>
    <item>
      <title>Re: Data managing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-managing/m-p/355810#M83349</link>
      <description>&lt;P&gt;Thank you for your time BallardW. I used the codes suggested by Darycut and it worked for me.&lt;/P&gt;&lt;P&gt;ThanKs anyway.&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2017 23:22:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-managing/m-p/355810#M83349</guid>
      <dc:creator>sijansap</dc:creator>
      <dc:date>2017-05-03T23:22:58Z</dc:date>
    </item>
  </channel>
</rss>

