<?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: Edit check in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/305530#M65181</link>
    <description>&lt;P&gt;Arrays should come in handy:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;array a {10};&lt;/P&gt;
&lt;P&gt;length flag $ 30;&lt;/P&gt;
&lt;P&gt;do i=1 to 10;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if a{i}=. then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if flag=' ' then flag = vname(a{i});&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else flag = trim(flag) || ',' || vname(a{i});&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just a side note:&amp;nbsp; I would suggest using a more meaningful name like MISSING_NUMS instead of FLAG.&amp;nbsp; But that's just a matter of style.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 18 Oct 2016 20:46:57 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-10-18T20:46:57Z</dc:date>
    <item>
      <title>Edit check</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/305511#M65175</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have dataset with ID as key variable and 10 variables A1-A10. I would like create 'flag' which will have all the Variables which have missing value.Flag should have variable names which are missing(Character or numeric). Below is example of the output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EX:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID &amp;nbsp; &amp;nbsp; &amp;nbsp; A1 A2 A3 &amp;nbsp; &amp;nbsp;A4&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;A5 &amp;nbsp; &amp;nbsp; A6 &amp;nbsp; &amp;nbsp; &amp;nbsp; A7 &amp;nbsp;A8 &amp;nbsp;A9 &amp;nbsp;A10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;FLAG&lt;/P&gt;
&lt;P&gt;001 &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; 1 &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp;TRT &amp;nbsp; TER &amp;nbsp; TEST &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;X &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A1,A3,,A7,A8,A10&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can someone help with above query. Thanks in Advance.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 19:42:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/305511#M65175</guid>
      <dc:creator>rakeshvvv</dc:creator>
      <dc:date>2016-10-18T19:42:17Z</dc:date>
    </item>
    <item>
      <title>Re: Edit check</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/305530#M65181</link>
      <description>&lt;P&gt;Arrays should come in handy:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;array a {10};&lt;/P&gt;
&lt;P&gt;length flag $ 30;&lt;/P&gt;
&lt;P&gt;do i=1 to 10;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if a{i}=. then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if flag=' ' then flag = vname(a{i});&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else flag = trim(flag) || ',' || vname(a{i});&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just a side note:&amp;nbsp; I would suggest using a more meaningful name like MISSING_NUMS instead of FLAG.&amp;nbsp; But that's just a matter of style.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 20:46:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/305530#M65181</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-18T20:46:57Z</dc:date>
    </item>
    <item>
      <title>Re: Edit check</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/305536#M65183</link>
      <description>&lt;P&gt;You should tell use which variables are actually numeric and which are character. It appears as though A1 - A3 might be numeric and the remainder character but I don't like to make assumptions.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2016 21:10:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/305536#M65183</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-10-18T21:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: Edit check</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/305573#M65196</link>
      <description>&lt;P&gt;To mix NUM and CHAR variables:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
infile cards pad;
input ID $3. (A1 A2 A3) (: 8.)  ( A4 - A10 )( : $4.);
call missing(of A7-A9);
cards;
001     .   1    .    TRT   TER   TEST   a   a a  X  
run;

data WANT;
  set HAVE;
  length MISSING_VAR_LIST $16;
  do _I=1 to 10;
    _VARNAME   =cats('A',_I);
    _VARVALUE  =left(vvaluex(_VARNAME)); 
    _VARTYPE   =vtypex(_VARNAME); 
    _IS_MISSING=ifn(_VARTYPE='C' &amp;amp; _VARVALUE=' ', 1
               ,ifn(_VARTYPE='N' &amp;amp; _VARVALUE='.', 1
               ,                                 0));   
    if _IS_MISSING then 
    MISSING_VAR_LIST=catx(',', MISSING_VAR_LIST, _VARNAME); 
  end;
  drop _:;
  putlog MISSING_VAR_LIST=;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;MISSING_VAR_LIST=A1,A3,A7,A8,A9&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 03:05:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/305573#M65196</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-10-19T03:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: Edit check</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/305578#M65198</link>
      <description>&lt;P&gt;If your variable names are not A1 to A10...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
  infile cards pad;
  input ID $3. (Q W E) (: 8.)  ( X T F R Y G S )( : $4.);
  call missing(R,Y,G);
cards;
001     .   1    .    TRT   TER   TEST   a   a a  X  
run;

data WANT;
  set HAVE;
  length MISSING_VAR_LIST _VARNAME $32 _VARVALUE _VARTYPE $1;
  do until (_VARNAME='ID');
    call vnext(_VARNAME,_VARTYPE);
  end;
  do _I=1 to 10;
    call vnext(_VARNAME,_VARTYPE);   
    _VARVALUE  =left(vvaluex(_VARNAME));  
    _IS_MISSING=ifn(_VARTYPE='C' &amp;amp; _VARVALUE=' ', 1
               ,ifn(_VARTYPE='N' &amp;amp; _VARVALUE='.', 1
               ,                                  0));   
    if _IS_MISSING then 
    MISSING_VAR_LIST=catx(',', MISSING_VAR_LIST, _VARNAME); 
  end;
  drop _:;
  putlog MISSING_VAR_LIST=;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;MISSING_VAR_LIST=Q,E,R,Y,G&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 03:45:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/305578#M65198</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-10-19T03:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: Edit check</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/305584#M65199</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
  infile cards pad;
  input ID $3. (Q W E) (: 8.)  ( X T F R Y G S )( : $4.);
  call missing(R,Y,G);
cards;
001     .   1    .    TRT   TER   TEST   a   a a  X  
;
run;
data want;
 set have;
 length _name_ flag $ 200;
 do while(_name_ ne '_name_');
  call vnext(_name_); 
  if _name_ ne '_name_' then do;
   if left(vvaluex(_name_)) in (' ','.') then flag=catx(',',flag,_name_);
  end;
 end;
 drop _name_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Oct 2016 05:34:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/305584#M65199</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-10-19T05:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: Edit check</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/305689#M65229</link>
      <description>&lt;P&gt;Excellent Sir...Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 15:16:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/305689#M65229</guid>
      <dc:creator>rakeshvvv</dc:creator>
      <dc:date>2016-10-19T15:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: Edit check</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/305795#M65278</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp﻿&lt;/a&gt;&amp;nbsp;You removed necessary checks.&lt;/P&gt;
&lt;P&gt;If you have a string equal to '.' it will be marked as missing when it is not.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 21:12:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/305795#M65278</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-10-19T21:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: Edit check</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/305809#M65287</link>
      <description>Good catch...</description>
      <pubDate>Wed, 19 Oct 2016 22:06:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/305809#M65287</guid>
      <dc:creator>rakeshvvv</dc:creator>
      <dc:date>2016-10-19T22:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: Edit check</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/305884#M65316</link>
      <description>&lt;P&gt;&amp;nbsp;OK. Using missing= system option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
  infile cards pad;
  input ID $3. (Q W E) (: 8.)  ( X T F R Y G S )( : $4.);
  call missing(R,Y,G);
cards;
001     .   1    .    TRT   TER   TEST   a   a a  X  
;
run;
options missing=' ';
data want;
 set have;
 length _name_ flag $ 200;
 do while(_name_ ne '_name_');
  call vnext(_name_); 
  if _name_ ne '_name_' then do;
   if missing(vvaluex(_name_)) then flag=catx(',',flag,_name_);
  end;
 end;
 drop _name_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Oct 2016 09:12:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/305884#M65316</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-10-20T09:12:39Z</dc:date>
    </item>
    <item>
      <title>Re: Edit check</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/306089#M65402</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp﻿&lt;/a&gt; No, You now miss all missing numerics.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 20:46:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/306089#M65402</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-10-20T20:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: Edit check</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/306148#M65426</link>
      <description>&lt;P&gt;Chris,&lt;/P&gt;
&lt;P&gt;No. I didn't miss. I check the result under UE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
  infile cards pad;
  input ID $3. (Q W E) (: 8.)  ( X T F R Y G S )( : $4.);
  X='.';
  call missing(R,Y,G);
cards;
001     .   1    .    TRT   TER   TEST   a   a a  X  
;
run;
options missing=' ';
data want;
 set have;
 length _name_ flag $ 200;
 do while(_name_ ne '_name_');
  call vnext(_name_); 
  if _name_ ne '_name_' then do;
   if missing(vvaluex(_name_)) then flag=catx(',',flag,_name_);
  end;
 end;
 drop _name_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/5402iA38DA8120F325377/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="x.png" title="x.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2016 01:51:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/306148#M65426</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-10-21T01:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: Edit check</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/306178#M65437</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp﻿&lt;/a&gt; Ah yes, i missed the&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;options&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;missing&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;' '&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Good thinking! &lt;/P&gt;
&lt;P&gt;Which highlights the point that this logic is not the best after all.&lt;/P&gt;
&lt;P&gt;Using vvaluex() means that any value formatted to ' ' will be shown as missing when it's not.&lt;/P&gt;
&lt;P&gt;One has to keep this limitation in mind if using the suggestions in these posts.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2016 04:33:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/306178#M65437</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-10-21T04:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: Edit check</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/306194#M65440</link>
      <description>&lt;P&gt;Chris,&lt;/P&gt;
&lt;P&gt;The safe way is make a format(.z .x. .... also are missing value in SAS)&lt;/P&gt;
&lt;P&gt;value fmt&lt;/P&gt;
&lt;P&gt;&amp;nbsp;._-.z=' ';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and format all the numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;format _numeric_ fmt. ;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2016 07:19:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/306194#M65440</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-10-21T07:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: Edit check</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/306680#M65609</link>
      <description>&lt;P&gt;So we have these 2 solutions now:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

%* Solution from KSharp;
proc format;
  value nummiss ._-.z=' ';
run;
data want;
 set have;        
 format _NUMERIC_ nummiss.;
 format _CHAR_ ;
 length _name_ flag $ 200;
 do while(_name_ ne '_name_');
  call vnext(_name_); 
  if _name_ ne '_name_' then do;
   if missing(vvaluex(_name_)) then flag=catx(',',flag,_name_);
  end;
 end;
 drop _name_;  
 putlog flag=;
run;

%* Solution from ChrisNZ;
data WANT;
  set HAVE;
  length _VARNAME $32 _VARVALUE _VARTYPE $1 MISSING_VAR_LIST $800 ;
  format _ALL_ ;
  do until( _VARNAME='_VARNAME') ;
    call vnext(_VARNAME,_VARTYPE);           
    _VARVALUE  =left(vvaluex(_VARNAME));  
    _IS_MISSING=ifn(_VARTYPE='C' &amp;amp; missing(_VARVALUE)  , 1
               ,ifn(_VARTYPE='N' &amp;amp; ^anydigit(_VARVALUE), 1
               ,                                         0));   
    if _IS_MISSING then 
    MISSING_VAR_LIST=catx(',', MISSING_VAR_LIST, _VARNAME); 
  end;
  drop _:;
  putlog MISSING_VAR_LIST=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 03:06:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Edit-check/m-p/306680#M65609</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-10-24T03:06:45Z</dc:date>
    </item>
  </channel>
</rss>

