<?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: how to add prefix to a column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241907#M44860</link>
    <description>&lt;P&gt;Making a few assumptions what your answers will be concerning the incoming data&amp;amp;colon;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if spouse &amp;gt; ' ' then spouse = 's' || employee_id;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This assumes that both of your incoming variables are character, and that SPOUSE is long enough to hold the "S" plus the ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would assume that if there is no current value for SPOUSE, then you would like to keep it blank.&lt;/P&gt;</description>
    <pubDate>Tue, 05 Jan 2016 20:20:37 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-01-05T20:20:37Z</dc:date>
    <item>
      <title>how to add prefix to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241892#M44854</link>
      <description>&lt;P&gt;i do have two columns where employee got his ID and i need to add employee id with prefix s to the spouse column .&lt;/P&gt;&lt;P&gt;i am confused about the synatx for spouse coumn .Thanks .&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2016 19:18:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241892#M44854</guid>
      <dc:creator>14sas</dc:creator>
      <dc:date>2016-01-05T19:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to add prefix to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241902#M44857</link>
      <description>&lt;P&gt;Are you using BASE SAS or EG?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you simply want to rename a column I recommend using PROC DATASETS to rename the variable.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000247719.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000247719.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc datasets library=work nolist nodetails;
modify DATASET_NAME;
rename employee_id=spouse_id;
run;quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Jan 2016 20:14:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241902#M44857</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-05T20:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to add prefix to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241903#M44858</link>
      <description>&lt;P&gt;Do you already have a spouse variable in a data set?&lt;/P&gt;
&lt;P&gt;Are you updating an existing data set or creating a new one?&lt;/P&gt;
&lt;P&gt;Is the employee id numeric or character?&lt;/P&gt;
&lt;P&gt;Is the prefix numeric or character?&lt;/P&gt;
&lt;P&gt;Is the spouse variable supposed to be numeric or character?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A generic for character variables could be&lt;/P&gt;
&lt;P&gt;spouse = cats(prefix,id);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2016 20:16:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241903#M44858</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-01-05T20:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to add prefix to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241906#M44859</link>
      <description>&lt;P&gt;Reeza i am using Base SAS .hERE IS THE CONDITION :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WHENEVER YOUR RELATIONSHIP CODE IS SPOUSE ,YOUR EMPLOYEE ID COLUMN HAS TO BE PREFIX+EMPLOYEEID.i AM REALLY CONFUSED BECAUSE ,SPOUSES GENERALLY WILL NOT HAVE EMPLOYEE ID HAS THIER ARE DEPENDENTS.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2016 20:18:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241906#M44859</guid>
      <dc:creator>14sas</dc:creator>
      <dc:date>2016-01-05T20:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: how to add prefix to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241907#M44860</link>
      <description>&lt;P&gt;Making a few assumptions what your answers will be concerning the incoming data&amp;amp;colon;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if spouse &amp;gt; ' ' then spouse = 's' || employee_id;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This assumes that both of your incoming variables are character, and that SPOUSE is long enough to hold the "S" plus the ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would assume that if there is no current value for SPOUSE, then you would like to keep it blank.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2016 20:20:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241907#M44860</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-01-05T20:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to add prefix to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241911#M44862</link>
      <description>Please post some sample data and expected output. If you don't understand the question or what you need to do, it's very hard for anyone else to suggest something without fully understanding your environment and data.</description>
      <pubDate>Tue, 05 Jan 2016 20:51:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241911#M44862</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-05T20:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: how to add prefix to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241915#M44864</link>
      <description>&lt;P&gt;here is the data &amp;amp;colon;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;emp_id&amp;nbsp;&amp;nbsp; relationshp_cd&amp;nbsp;&lt;/P&gt;&lt;P&gt;1234&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; employee&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;nil&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dependent&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;now the output has to be :&lt;/P&gt;&lt;P&gt;emp_id&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; relationshp_cd&lt;/P&gt;&lt;P&gt;1234&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; employee&lt;/P&gt;&lt;P&gt;S1234&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DEPENDENT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2016 20:59:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241915#M44864</guid>
      <dc:creator>14sas</dc:creator>
      <dc:date>2016-01-05T20:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to add prefix to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241917#M44866</link>
      <description>I understand the request, but I think you'll need to post more sample data. How do I know that the dependent is linked to the employee for example? I'm assuming there's another field that shows the relationship or another table.</description>
      <pubDate>Tue, 05 Jan 2016 21:07:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241917#M44866</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-05T21:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to add prefix to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241918#M44867</link>
      <description>There are specific ids ,which explain thier relation ship .</description>
      <pubDate>Tue, 05 Jan 2016 21:13:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241918#M44867</guid>
      <dc:creator>14sas</dc:creator>
      <dc:date>2016-01-05T21:13:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to add prefix to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241919#M44868</link>
      <description>&lt;P&gt;Please post some example data that illustrates the full scope of the problem, including the field to link the rows.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2016 21:18:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241919#M44868</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-05T21:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: how to add prefix to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241926#M44875</link>
      <description>emp _id relationshp_cd uniq_id&lt;BR /&gt;1234 employee a123401&lt;BR /&gt;3456 employee a0987601&lt;BR /&gt;nil dependent a0987602</description>
      <pubDate>Tue, 05 Jan 2016 21:38:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241926#M44875</guid>
      <dc:creator>14sas</dc:creator>
      <dc:date>2016-01-05T21:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to add prefix to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241928#M44876</link>
      <description>&lt;P&gt;The spouse column already exists as membership_cd as dependent , employee_id is numeric, in my desired output whenever membership_cd is dependent , in the employee_id it has to be Semployee_id , where s is the character adding to employee_id&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2016 22:06:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241928#M44876</guid>
      <dc:creator>14sas</dc:creator>
      <dc:date>2016-01-05T22:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to add prefix to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241929#M44877</link>
      <description>&lt;P&gt;I want employee_id for spouse as S+ employee_id of the spouse&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2016 22:08:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241929#M44877</guid>
      <dc:creator>14sas</dc:creator>
      <dc:date>2016-01-05T22:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: how to add prefix to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241932#M44879</link>
      <description>&lt;P&gt;This basically a look up. Join the table to itself to find the corresponding record and update the field.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've modified your data slightly to make it easier to join for me, you'll have to tweak it to match your actual data conditions, but hopefully it gives you an idea of how to get started. If you need more help, please explain what doesn't work and provide more sample data that aligns with your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Generate sample data*/
data have;
infile cards dsd truncover;
informat relationshp_cd $12.;
input  order_var emp_id $  relationshp_cd $  uniq_id $;
cards;
1, 1234, employee,  a123401
2, 3456, employee,  a987601
3,    , dependent, a987602
;
run;

/*Create Spousal ID*/
proc sql;
create table want as
select a.order_var,
       coalesce(a.emp_id, cats("S", b.emp_id)) as emp_id,
		a.relationshp_cd,
		a.uniq_id
from have as a
left join have as b
/*this is the condition you need to modify to meet your joining criteria*/
on substr(a.uniq_id, 1, 5)=substr(b.uniq_id, 1, 5)
and b.relationshp_cd='employee'
order by a.order_var;
quit;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Jan 2016 22:20:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/241932#M44879</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-05T22:20:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to add prefix to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/242009#M44902</link>
      <description>&lt;P&gt;You can also try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;New_Col = Compress(Prefix||Your_col);&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2016 11:45:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/242009#M44902</guid>
      <dc:creator>Tanmay</dc:creator>
      <dc:date>2016-01-06T11:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to add prefix to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/242042#M44911</link>
      <description>&lt;P&gt;this wont be a new column ,just whenever your relationship_cd is dependent ,emp_id has to be prefix + emp_id .&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2016 15:14:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/242042#M44911</guid>
      <dc:creator>14sas</dc:creator>
      <dc:date>2016-01-06T15:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to add prefix to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/242048#M44914</link>
      <description>when i try this ,emp_id for dependents coming up only with prefix instead of prefix+emp_id .</description>
      <pubDate>Wed, 06 Jan 2016 15:25:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/242048#M44914</guid>
      <dc:creator>14sas</dc:creator>
      <dc:date>2016-01-06T15:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to add prefix to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/242053#M44915</link>
      <description>Then either your join condition is incorrect or you need to trim the fields of blanks before concatenating them.  Post your code.</description>
      <pubDate>Wed, 06 Jan 2016 15:28:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/242053#M44915</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-06T15:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: how to add prefix to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/242071#M44917</link>
      <description>&lt;P&gt;This is my program:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table TEST as&amp;nbsp;&lt;/P&gt;&lt;P&gt;where relationship_cd ='s' then employee_id = "S"II ''II (employee_id)&lt;/P&gt;&lt;P&gt;else trim (employee_id)&lt;/P&gt;&lt;P&gt;end as employee_id&lt;/P&gt;&lt;P&gt;from master_file&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2016 16:35:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/242071#M44917</guid>
      <dc:creator>14sas</dc:creator>
      <dc:date>2016-01-06T16:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to add prefix to a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/242075#M44918</link>
      <description>That's not valid code, there weren't errors in the log?</description>
      <pubDate>Wed, 06 Jan 2016 17:05:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-add-prefix-to-a-column/m-p/242075#M44918</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-06T17:05:12Z</dc:date>
    </item>
  </channel>
</rss>

