<?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 syntax to use for accomplishing task in coding with SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-syntax-to-use-for-accomplishing-task-in-coding/m-p/377964#M276761</link>
    <description>&lt;P&gt;Something like this perhaps?&lt;/P&gt;
&lt;PRE&gt;data have;
 input x                         y                         z;
datalines;
.                          1                         .
6                         1                        9
6                         1                        9
.                          1                        9
.                          1                        9
8                         2                        7
8                         2                        7
.                          2                        .
.                          2                        .
.                          2                        .
.                          3                        .
.                          3                        .
.                          3                        .
5                         3                        4 
;
run;

proc sql;
   create table want as
   select a.y, b.x,b.z
   from have as a
        left join
        (select y, max(x) as x, max(z) as z
         from have
         group by y) as b
      on a.y=b.y;
quit;&lt;/PRE&gt;
&lt;P&gt;Note that if your variables x and z are character the MAX function may not return what I am guessing you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Jul 2017 23:37:56 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-07-20T23:37:56Z</dc:date>
    <item>
      <title>Need help with syntax to use for accomplishing task in coding with SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-syntax-to-use-for-accomplishing-task-in-coding/m-p/377946#M276759</link>
      <description>&lt;P&gt;Hello, I would like to know if anyone out there is able to help me write the SAS code for the following task:&lt;/P&gt;&lt;P&gt;Here is the scenario:&lt;/P&gt;&lt;P&gt;(a) My data has 3 variables x,y &amp;amp; z&lt;/P&gt;&lt;P&gt;(b) All of my y fields are populated but only some of the x and z fields are populated. As long as an x field has a value, the z field also has to have a value.&lt;/P&gt;&lt;P&gt;(c) Some of the values in the y field are the same which means that their x and y values will always be the same as well.&lt;/P&gt;&lt;P&gt;HERE'S HOW MY DATA LOOKS...&lt;/P&gt;&lt;P&gt;x &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; y &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; z&lt;/P&gt;&lt;P&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;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;6 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9&lt;/P&gt;&lt;P&gt;6 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9&lt;/P&gt;&lt;P&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;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9&lt;/P&gt;&lt;P&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;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9&lt;/P&gt;&lt;P&gt;8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7&lt;/P&gt;&lt;P&gt;8 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7&lt;/P&gt;&lt;P&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;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HERE'S MY QUESTION:&lt;/P&gt;&lt;P&gt;How do I write a code so that I do not need to manually input all the missing x and z values in my dataset given that all of my y's are populated and I have values for some of their x and z's???&lt;/P&gt;&lt;P&gt;Hope someone out there can help me...&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;dede1&lt;/P&gt;&lt;P&gt;ps - I'm using v9.4&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 21:44:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-syntax-to-use-for-accomplishing-task-in-coding/m-p/377946#M276759</guid>
      <dc:creator>dede1</dc:creator>
      <dc:date>2017-07-20T21:44:15Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with syntax to use for accomplishing task in coding with SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-syntax-to-use-for-accomplishing-task-in-coding/m-p/377947#M276760</link>
      <description>&lt;P&gt;Show what you want please.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 21:45:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-syntax-to-use-for-accomplishing-task-in-coding/m-p/377947#M276760</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-20T21:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with syntax to use for accomplishing task in coding with SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-syntax-to-use-for-accomplishing-task-in-coding/m-p/377964#M276761</link>
      <description>&lt;P&gt;Something like this perhaps?&lt;/P&gt;
&lt;PRE&gt;data have;
 input x                         y                         z;
datalines;
.                          1                         .
6                         1                        9
6                         1                        9
.                          1                        9
.                          1                        9
8                         2                        7
8                         2                        7
.                          2                        .
.                          2                        .
.                          2                        .
.                          3                        .
.                          3                        .
.                          3                        .
5                         3                        4 
;
run;

proc sql;
   create table want as
   select a.y, b.x,b.z
   from have as a
        left join
        (select y, max(x) as x, max(z) as z
         from have
         group by y) as b
      on a.y=b.y;
quit;&lt;/PRE&gt;
&lt;P&gt;Note that if your variables x and z are character the MAX function may not return what I am guessing you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 23:37:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-syntax-to-use-for-accomplishing-task-in-coding/m-p/377964#M276761</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-07-20T23:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with syntax to use for accomplishing task in coding with SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-with-syntax-to-use-for-accomplishing-task-in-coding/m-p/377973#M276762</link>
      <description>&lt;P&gt;Thank you so much ballardw! Your code worked for what I needed!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dede1&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 01:38:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-with-syntax-to-use-for-accomplishing-task-in-coding/m-p/377973#M276762</guid>
      <dc:creator>dede1</dc:creator>
      <dc:date>2017-07-21T01:38:02Z</dc:date>
    </item>
  </channel>
</rss>

