<?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: Need help with coding in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-coding/m-p/630497#M186663</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/315580"&gt;@asabou01&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank for your quick response - but - unfortunately it is not working.&lt;BR /&gt;This is the output when I ran your code:&lt;BR /&gt;Obs ID NET1 NET2 NET3&lt;BR /&gt;&lt;BR /&gt;1 HMO POS PPO&lt;BR /&gt;2 POS PPO&lt;BR /&gt;3 PPO&lt;BR /&gt;This is what I am trying to get:&lt;BR /&gt;ID NET1 NET2 NET3&lt;BR /&gt;ID1 HMO POS PPO&lt;BR /&gt;ID2 POS PPO&lt;BR /&gt;ID3 PPO&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I thought you want to change where the missing values were?&amp;nbsp; This print out look like your original input.&lt;/P&gt;
&lt;P&gt;Please post some example data, preferable in the form of a simple data step that can be copied and run.&amp;nbsp; Make sure to show the expected output for the given example, again in a way that is reproducible.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make sure when posting code to use the Insert SAS code button the editor window.&lt;/P&gt;</description>
    <pubDate>Sun, 08 Mar 2020 16:53:43 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-03-08T16:53:43Z</dc:date>
    <item>
      <title>Need help with coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-coding/m-p/630419#M186637</link>
      <description>&lt;P&gt;Can someone help me convert TABLE 1 below to TABLE 2 by streamlining values (using SAS windows 9.4):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data temp;&lt;BR /&gt;infile datalines ;&lt;BR /&gt;input @1 ID $3. @5 NET1 $3. @9 NET2 $3. &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/83330"&gt;@13&lt;/a&gt; NET3 $3.;&lt;BR /&gt;datalines;&lt;BR /&gt;HMO POS PPO&lt;BR /&gt;POS PPO&lt;BR /&gt;PPO&lt;BR /&gt;;&lt;BR /&gt;proc print data=temp;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*&lt;BR /&gt;&lt;BR /&gt;Table 1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NET1 NET2 NET3&lt;BR /&gt;ID1&amp;nbsp; HMO&amp;nbsp; POS&amp;nbsp; &amp;nbsp;PPO&lt;BR /&gt;ID2&amp;nbsp; POS&amp;nbsp; &amp;nbsp;PPO&lt;BR /&gt;ID3&amp;nbsp; PPO&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table 2&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NET1 NET2 NET3&lt;BR /&gt;ID1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; HMO POS&amp;nbsp; &amp;nbsp; PPO&lt;BR /&gt;ID2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;POS&amp;nbsp; &amp;nbsp; PPO&lt;BR /&gt;ID3&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; PPO&lt;/P&gt;</description>
      <pubDate>Sat, 07 Mar 2020 21:21:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-coding/m-p/630419#M186637</guid>
      <dc:creator>asabou01</dc:creator>
      <dc:date>2020-03-07T21:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-coding/m-p/630421#M186639</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data temp;
infile datalines truncover;
input  ID :$3. (net1-net3) (:$3.);
datalines;
ID1  HMO  POS   PPO
ID2  POS   PPO
ID3  PPO
;

data want;
 set temp;
 call sortc(of net:);
run;

proc print noobs;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;ID&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;net1&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;net2&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;net3&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;ID1&lt;/TD&gt;
&lt;TD class="l data"&gt;HMO&lt;/TD&gt;
&lt;TD class="l data"&gt;POS&lt;/TD&gt;
&lt;TD class="l data"&gt;PPO&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;ID2&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;POS&lt;/TD&gt;
&lt;TD class="l data"&gt;PPO&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;ID3&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="l data"&gt;PPO&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Sat, 07 Mar 2020 21:37:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-coding/m-p/630421#M186639</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-07T21:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-coding/m-p/630428#M186641</link>
      <description>&lt;P&gt;This feels a little like a jeopardy game puzzle.&amp;nbsp; Am I supposed to first supply the question before I give the code?&lt;/P&gt;
&lt;P&gt;Sounds like your question is how do I right align the values in a set of variables.&lt;/P&gt;
&lt;P&gt;Is the issue is to move all of the non-missing values to the right?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  id+1;
  input (net1-net3) (:$3.);
datalines;
HMO POS PPO
POS PPO .
PPO .   .
. PPO .
;
proc print;
 title 'HAVE';
run;

data want ;
  set have;
  array net net1-net3;
  nmiss=0;
  do loc=dim(net) to 1 by -1 ;
    do nmiss=nmiss to loc-1 while (missing(net[loc-nmiss])); end;
    if 0 &amp;lt; (loc-nmiss) then net[loc]=net[loc-nmiss];
    else net[loc]=' ';
  end;
  drop nmiss loc;
run;

proc print;
 title 'WANT';
run;
title;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 248px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36677i2E616B5DAF6D223B/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Mar 2020 22:29:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-coding/m-p/630428#M186641</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-07T22:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-coding/m-p/630430#M186642</link>
      <description>&lt;P&gt;So you decided the question was how to sort the values in an array (set of variables).&lt;/P&gt;</description>
      <pubDate>Sat, 07 Mar 2020 22:30:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-coding/m-p/630430#M186642</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-07T22:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-coding/m-p/630431#M186643</link>
      <description>&lt;P&gt;Sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; I didn't pay the kind of attention to detail like you did. I wholeheartedly admit, It was a cheeky assumption&lt;/P&gt;</description>
      <pubDate>Sat, 07 Mar 2020 22:33:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-coding/m-p/630431#M186643</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-03-07T22:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-coding/m-p/630459#M186649</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
infile datalines truncover;
input  ID :$3. (net1-net3) (:$3.);
datalines;
ID1  HMO  POS   PPO
ID2  POS   PPO
ID3  PPO
;
data want;
 set temp;
 array x{*} $ net1-net3 ;
 array y{*} $ 80 _net1-_net3 ;
 n=dim(x)+1;
 do i=dim(x) to 1 by -1;
   if not missing(x{i}) then do;n+(-1);y{n}=x{i};end;
 end;
 drop i n net1-net3;
 run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 08 Mar 2020 04:38:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-coding/m-p/630459#M186649</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-03-08T04:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-coding/m-p/630485#M186659</link>
      <description>Thank for your quick response - but - unfortunately it is not working.&lt;BR /&gt;This is the output when I ran your code:&lt;BR /&gt;Obs ID NET1 NET2 NET3&lt;BR /&gt;&lt;BR /&gt;1 HMO POS PPO&lt;BR /&gt;2 POS PPO&lt;BR /&gt;3 PPO&lt;BR /&gt;This is what I am trying to get:&lt;BR /&gt;ID NET1 NET2 NET3&lt;BR /&gt;ID1 HMO POS PPO&lt;BR /&gt;ID2 POS PPO&lt;BR /&gt;ID3 PPO&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 08 Mar 2020 13:37:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-coding/m-p/630485#M186659</guid>
      <dc:creator>asabou01</dc:creator>
      <dc:date>2020-03-08T13:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-coding/m-p/630494#M186661</link>
      <description>Hi again, I am sorry to take your time again but your wonderful solution only worked partly and when I applied it to more observation it did not work.&lt;BR /&gt;Attached are samples with more obs. I appreciate it if you can take a second look.&lt;BR /&gt;</description>
      <pubDate>Sun, 08 Mar 2020 16:25:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-coding/m-p/630494#M186661</guid>
      <dc:creator>asabou01</dc:creator>
      <dc:date>2020-03-08T16:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-coding/m-p/630497#M186663</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/315580"&gt;@asabou01&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank for your quick response - but - unfortunately it is not working.&lt;BR /&gt;This is the output when I ran your code:&lt;BR /&gt;Obs ID NET1 NET2 NET3&lt;BR /&gt;&lt;BR /&gt;1 HMO POS PPO&lt;BR /&gt;2 POS PPO&lt;BR /&gt;3 PPO&lt;BR /&gt;This is what I am trying to get:&lt;BR /&gt;ID NET1 NET2 NET3&lt;BR /&gt;ID1 HMO POS PPO&lt;BR /&gt;ID2 POS PPO&lt;BR /&gt;ID3 PPO&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I thought you want to change where the missing values were?&amp;nbsp; This print out look like your original input.&lt;/P&gt;
&lt;P&gt;Please post some example data, preferable in the form of a simple data step that can be copied and run.&amp;nbsp; Make sure to show the expected output for the given example, again in a way that is reproducible.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make sure when posting code to use the Insert SAS code button the editor window.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Mar 2020 16:53:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-coding/m-p/630497#M186663</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-08T16:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-coding/m-p/630539#M186669</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
 set hh.test;
 array x1{*} $ net1-net7 ;
 array x2{*} count1-count7;
 array x3{*} allow1-allow7;

 array y1{*} $ 80 _net1-_net7 ;
 array y2{*}  _count1-_count7 ;
 array y3{*}  _allow1-_allow7;

 n1=dim(x1)+1; n2=dim(x2)+1; n3=dim(x3)+1;


do i=dim(x1) to 1 by -1;
   if not missing(x1{i}) then do;
    n1+(-1);y1{n1}=x1{i};
   end;
 end;

do j=dim(x2) to 1 by -1;
   if not missing(x2{j}) then do;
    n2+(-1);y2{n2}=x2{j};
   end;
 end;

do k=dim(x3) to 1 by -1;
   if not missing(x3{k}) then do;
    n3+(-1);y3{n3}=x3{k};
   end;
 end;
 drop i j k n1 n2 n3 net1-net7 count1-count7 allow1-allow7;
 run;


proc export data=want
            outfile="c:\want.xlsx" replace
			dbms=excel;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Mar 2020 00:07:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-coding/m-p/630539#M186669</guid>
      <dc:creator>asabou01</dc:creator>
      <dc:date>2020-03-09T00:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with coding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-coding/m-p/630580#M186681</link>
      <description>&lt;P&gt;Post your new data and new output . and I could offer new code .&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 05:35:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-coding/m-p/630580#M186681</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-03-09T05:35:47Z</dc:date>
    </item>
  </channel>
</rss>

