<?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: Keep variable values across rows in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Rename-and-gather-people-through-another-table/m-p/427739#M105533</link>
    <description>&lt;P&gt;You can use RETAIN and FIRST logic to keep the first value. The number of rows don't matter but the data does need to be in the order specified, similar to your demo data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="delete_retain example.JPG" style="width: 428px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17868i3CABC61A1CF7FADB/image-size/large?v=v2&amp;amp;px=999" role="button" title="delete_retain example.JPG" alt="delete_retain example.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 15 Jan 2018 16:05:14 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-01-15T16:05:14Z</dc:date>
    <item>
      <title>Rename and gather people through another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-and-gather-people-through-another-table/m-p/427576#M105489</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a first table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Name C1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thomas 5&lt;/P&gt;&lt;P&gt;To 5&lt;/P&gt;&lt;P&gt;Fab 4&lt;/P&gt;&lt;P&gt;Fabien 4&lt;/P&gt;&lt;P&gt;Nelson 9&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2 nd table&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Fabien&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;P&gt;Nelson&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to create a 3rd table that brings together individuals with the same values of 'C1'.&lt;BR /&gt;But that the value of 'Name' is the one present in table 2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to get this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Name C1 Count&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Fabien 5&amp;nbsp; 2&lt;/P&gt;&lt;P&gt;Thomas 4 2&lt;/P&gt;&lt;P&gt;Nelson 9 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not want to rename the values of name.&lt;BR /&gt;And I would like to have a variable count that counts the number of times that the individual appeared&lt;BR /&gt;Example: Fabien and Fab count = 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 08:20:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-and-gather-people-through-another-table/m-p/427576#M105489</guid>
      <dc:creator>WilliamB</dc:creator>
      <dc:date>2018-01-15T08:20:12Z</dc:date>
    </item>
    <item>
      <title>Gathering information</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-and-gather-people-through-another-table/m-p/427573#M105529</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a first SAS table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Name C1&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thomas 2&amp;nbsp;&lt;/P&gt;&lt;P&gt;Fabien 7&lt;/P&gt;&lt;P&gt;Nelson 9&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2nd Sas table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Name R1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thomas TB&lt;/P&gt;&lt;P&gt;Fabien AB&lt;/P&gt;&lt;P&gt;Didier Ajac&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;I would like to create a 3rd table, which shows the individuals in table 1 who are present in table 2, and concatenate the characteristics. But keep all individuals from table 2 even if they are not present in table 1.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If possible in proc SQL.&amp;nbsp;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to get this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Name C1 R1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thomas 2 TB&lt;/P&gt;&lt;P&gt;Fabien 7&amp;nbsp; &amp;nbsp;AB&lt;/P&gt;&lt;P&gt;Didier .&amp;nbsp; &amp;nbsp;Ajac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jan 2018 23:14:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-and-gather-people-through-another-table/m-p/427573#M105529</guid>
      <dc:creator>WilliamB</dc:creator>
      <dc:date>2018-01-14T23:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: Gathering information</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-and-gather-people-through-another-table/m-p/427574#M105530</link>
      <description>&lt;P&gt;left join using table2 as left table on name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table1;
input (Name C1) ($);
datalines;
Thomas 2 
Fabien 7
Nelson 9
;

data table2;
input (Name r1) ($);
datalines;
Thomas TB
Fabien AB
Didier Ajac
;

proc sql;
create table want as
select a.*,c1, catx(' ',r1, c1) as concat_chars_for_op
from table2 a left join table1 b
on a.name=b.name
order by name desc;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 14 Jan 2018 23:27:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-and-gather-people-through-another-table/m-p/427574#M105530</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-14T23:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: Rename and gather people through another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-and-gather-people-through-another-table/m-p/427579#M105492</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table1;
input (Name C1) ($);
datalines;
Thomas 2 
Fabien 7
Nelson 9
;

data table2;
input (_Name r1) ($);
datalines;
Thomas TB
Fabien AB
Didier Ajac
;



proc sql;
create table want as
select a.*,cnt+1 as count
from table2 a left join (select Name,count(name) as cnt from table1 group by name) b
on a._name=b.name;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 14 Jan 2018 23:38:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-and-gather-people-through-another-table/m-p/427579#M105492</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-14T23:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: Rename and gather people through another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-and-gather-people-through-another-table/m-p/427585#M105498</link>
      <description>&lt;P&gt;&lt;BR /&gt;data table1;&lt;BR /&gt;input (_Name C1) ($);&lt;BR /&gt;datalines;&lt;BR /&gt;Thomas 2&lt;BR /&gt;Fabien 7&lt;BR /&gt;Nelson 9&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;data table2;&lt;BR /&gt;input (_Name r1) ($);&lt;BR /&gt;datalines;&lt;BR /&gt;Thomas TB&lt;BR /&gt;Fabien AB&lt;BR /&gt;Didier Ajac&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data=table1;by _name;run;&lt;/P&gt;&lt;P&gt;proc sort data=table2;by _name;run;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;merge table1(in=a) table2(in=b);&lt;BR /&gt;by _name;&lt;BR /&gt;if a;&lt;BR /&gt;if a and b then count=2;&lt;BR /&gt;proc sort ;by _name;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 00:17:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-and-gather-people-through-another-table/m-p/427585#M105498</guid>
      <dc:creator>rajeshalwayswel</dc:creator>
      <dc:date>2018-01-15T00:17:26Z</dc:date>
    </item>
    <item>
      <title>Keep variable values across rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-and-gather-people-through-another-table/m-p/427617#M105531</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sas Table&lt;/P&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have a first SAS table&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Name C1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thomas 1&lt;/P&gt;
&lt;P&gt;Tho 1&lt;/P&gt;
&lt;P&gt;Fabien 2&lt;/P&gt;
&lt;P&gt;Fab&amp;nbsp; &amp;nbsp;2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to create a program where if C1 (n) = C1 (n-1) from the observation before then Name (n ) = Name (n-1)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I want to get this&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Name C1&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thomas 1&lt;/P&gt;
&lt;P&gt;Thomas 1&lt;/P&gt;
&lt;P&gt;Fabien 2&lt;/P&gt;
&lt;P&gt;Fabien 2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a very large table, so I can not rename individually any observation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks for your help&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 15:52:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-and-gather-people-through-another-table/m-p/427617#M105531</guid>
      <dc:creator>WilliamB</dc:creator>
      <dc:date>2018-01-15T15:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: Automatically rename</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-and-gather-people-through-another-table/m-p/427618#M105532</link>
      <description>&lt;P&gt;This has nothing to do with renaming variables.&amp;nbsp; Variables are the columns, observations are the elements.&amp;nbsp; What you are looking at is coding the observations you have.&amp;nbsp; You can do this in a number of ways, proc format for instance, retain first value down.&amp;nbsp; My personal preference would be to create a decode table, a smaller table containing distinct c1 and name, as they should be fully, then joining this table on when needed.&amp;nbsp; E.g.&lt;/P&gt;
&lt;PRE&gt;/* Note I do this step so I get the longest name, I assume this is your logic */
data inter;
  set have;
  l=lengthn(name);
run;

proc sort data=inter;
  by c1 name descending l;
run;

proc sort data=inter nodupkey;
  by c1 name;
run;

/* Now use it to merge on */
data want;
  merge have inter (rename=(name=full_name));
  by c1;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Jan 2018 09:01:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-and-gather-people-through-another-table/m-p/427618#M105532</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-01-15T09:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: Rename and gather people through another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-and-gather-people-through-another-table/m-p/427659#M105522</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t1;
input Name $ C1;
cards;
Thomas 5
To 5
Fab 4
Fabien 4
Nelson 9
;
run;

 

data t2;
input name $;
cards; 
Fabien 
Thomas
Nelson
;
run;
proc sql;
create table want as
 select a.*,b.c1,b.n
  from t2 as a left join
(select *,count(*) as n from t1 group by c1 having length(name)=max(length(name))) as b
   on a.name=b.name;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Jan 2018 12:54:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-and-gather-people-through-another-table/m-p/427659#M105522</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-01-15T12:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: Keep variable values across rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-and-gather-people-through-another-table/m-p/427739#M105533</link>
      <description>&lt;P&gt;You can use RETAIN and FIRST logic to keep the first value. The number of rows don't matter but the data does need to be in the order specified, similar to your demo data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="delete_retain example.JPG" style="width: 428px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17868i3CABC61A1CF7FADB/image-size/large?v=v2&amp;amp;px=999" role="button" title="delete_retain example.JPG" alt="delete_retain example.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 16:05:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-and-gather-people-through-another-table/m-p/427739#M105533</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-15T16:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: Rename and gather people through another table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-and-gather-people-through-another-table/m-p/427753#M105535</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/112281"&gt;@WilliamB&lt;/a&gt;&amp;nbsp;please do not post the same question multiple times. I've merged your three posts into one.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2018 16:45:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-and-gather-people-through-another-table/m-p/427753#M105535</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-15T16:45:32Z</dc:date>
    </item>
  </channel>
</rss>

