<?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: Combing names from dataset with column names in other dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Combing-names-from-dataset-with-column-names-in-other-dataset/m-p/515258#M138994</link>
    <description>Sounds like a candidate for a data _null_ step to call execute a proc datasets that will change column names and install those descriptive labels</description>
    <pubDate>Wed, 21 Nov 2018 22:49:45 GMT</pubDate>
    <dc:creator>Peter_C</dc:creator>
    <dc:date>2018-11-21T22:49:45Z</dc:date>
    <item>
      <title>Combing names from dataset with column names in other dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combing-names-from-dataset-with-column-names-in-other-dataset/m-p/515056#M138942</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have&amp;nbsp;dataset&amp;nbsp;that looks like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;refper	company			placeholder_r0010			placeholder_r0020 	placeholder_r0030 		placeholder_r0040 		&lt;BR /&gt;&lt;BR /&gt;201744	70912	.          	71.889.742,2000000000	.          	539.285,3600000000	26.431.317.719,6000000000	1.846.511.611,3300000000
201841	70912	.          	85.787.103,2700000000	.          	539.285,3600000000	26.066.828.054,7500000000	1.751.692.394,5900000000
201842	70912	.          	-43.904.340,3200000000	.          	539.285,3600000000	26.937.620.831,9400000000	2.043.105.368,9100000000
201843	70912	.          	.          		.          	537.775,2200000000	27.011.686.026,8700000000	1.215.625.799,2800000000&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and another dataset which combines the placeholder column names with their actual names:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Goodwill			R0010
Deferred acquisition costs	R0020
Intangible assets		R0030
Deferred tax assets		R0040&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;How do I combine these two sets such that the column names in the first dataset&amp;nbsp;changes to names given&amp;nbsp;in the second data set? (such that: placeholder_r0010 == Goodwill, placeholder_r0020&amp;nbsp;== Deferred acquisition costs, ...)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2018 12:46:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combing-names-from-dataset-with-column-names-in-other-dataset/m-p/515056#M138942</guid>
      <dc:creator>Thorius_Prime</dc:creator>
      <dc:date>2018-11-21T12:46:08Z</dc:date>
    </item>
    <item>
      <title>Re: Combing names from dataset with column names in other dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combing-names-from-dataset-with-column-names-in-other-dataset/m-p/515069#M138959</link>
      <description>&lt;P&gt;Ignore everything to the right of "placeholder_r0040". The website is not working with me.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2018 12:48:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combing-names-from-dataset-with-column-names-in-other-dataset/m-p/515069#M138959</guid>
      <dc:creator>Thorius_Prime</dc:creator>
      <dc:date>2018-11-21T12:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: Combing names from dataset with column names in other dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combing-names-from-dataset-with-column-names-in-other-dataset/m-p/515070#M138960</link>
      <description>&lt;P&gt;I would ask why your in this situation in the first place, i.e. having placeholders and names in another dataset.&amp;nbsp; Its likely a bad import, or export at some part of the process and fixing it there would be more beneficial.&amp;nbsp; Anyways, something like - and please post test data in the form of a datastep:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;In future!&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table inter as
  select cats(a.name,"=",tranwrd(b.dsname," ","_")) as ren
  from    (select * from sashelp.vcolumns where libname="&amp;lt;yourlib&amp;gt;" and memname="&amp;lt;yourds&amp;gt;") a
  left join ds b
  on       scan(a.name,"_",2)=b.col2;
quit;

data _null_;
  set inter end=last;;
  if _n_=1 then call execute('data want; set have (rename=(');
  call execute(ren);
  if last. then call execute('));run;');
run;&lt;/PRE&gt;
&lt;P&gt;What this does (and no test data so you will need to update for your data!!) is to create a rename list of variable name to text in second table - remembering that variable names cannot have spaces so these are replaced with _.&amp;nbsp; This list of renames is then used in a generated datastep from the data _null_;&amp;nbsp; You could (and probably should, use proc datasets rather than datastep).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2018 12:48:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combing-names-from-dataset-with-column-names-in-other-dataset/m-p/515070#M138960</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-21T12:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: Combing names from dataset with column names in other dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combing-names-from-dataset-with-column-names-in-other-dataset/m-p/515073#M138961</link>
      <description>&lt;P&gt;Create a format from the second dataset.&lt;/P&gt;
&lt;P&gt;Transpose the first dataset to a usable (long) format.&lt;/P&gt;
&lt;P&gt;Remove the "placeholder_" from the _name_ column, and apply the format to it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that the "names" from your second dataset can't be used in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2018 12:56:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combing-names-from-dataset-with-column-names-in-other-dataset/m-p/515073#M138961</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-21T12:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: Combing names from dataset with column names in other dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combing-names-from-dataset-with-column-names-in-other-dataset/m-p/515074#M138962</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Spaces in variables names are not a goodf idea. The following program used the provided names&lt;/P&gt;
&lt;P&gt;with spaces replaced by underscores.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    length refper company placeholder_r0010 placeholder_r0020  placeholder_r0030  placeholder_r0040 3.;
    call missing(of _ALL_);
run;

data placeholders;
    infile cards dlm="," dsd;
	length name $30.;
    input name $ code $;
    cards;
Goodwill                   , R0010
Deferred acquisition costs , R0020
Intangible assets          , R0030
Deferred tax assets        , R0040
;
run;

data _NULL_;
    set placeholders end=eof;

    if _N_=1 then call execute('data want; set have;');

    call execute(cats('rename placeholder_',code,'=',tranwrd(strip(name)," ","_"),';'));

    if eof then call execute('run;');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Nov 2018 12:57:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combing-names-from-dataset-with-column-names-in-other-dataset/m-p/515074#M138962</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-11-21T12:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: Combing names from dataset with column names in other dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combing-names-from-dataset-with-column-names-in-other-dataset/m-p/515076#M138963</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/229187"&gt;@Thorius_Prime&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The website is not working with me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Because you have tabs in something that should be code. This is a VERY BAD IDEA.&lt;/P&gt;
&lt;P&gt;Create a data step with datalines, and post that.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Nov 2018 13:01:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combing-names-from-dataset-with-column-names-in-other-dataset/m-p/515076#M138963</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-21T13:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: Combing names from dataset with column names in other dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combing-names-from-dataset-with-column-names-in-other-dataset/m-p/515079#M138964</link>
      <description>&lt;P&gt;Transpose and format, with usable example data:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ds1;
input refper $ company $ (placeholder_r0010 placeholder_r0020 placeholder_r0030 placeholder_r0040) (:commax32.);
datalines;
201744 70912 . 71.889.742,2000000000 . 539.285,3600000000
201841 70912 . 85.787.103,2700000000 . 539.285,3600000000
201842 70912 . -43.904.340,3200000000 . 539.285,3600000000
201843 70912 . . . 537.775,2200000000
;
run;

data ds2;
infile datalines dlm=',';
input label :$32. start $;
fmtname = 'mylabel';
type = 'C';
datalines;
Goodwill,R0010
Deferred acquisition costs,R0020
Intangible assets,R0030
Deferred tax assets,R0040
;
run;

proc format cntlin=ds2;
run;

proc transpose
  data=ds1
  out=trans (
    rename=(_name_=type col1=value)
  )
;
by refper company;
var placeholder:;
run;

data want;
set trans;
type = upcase(scan(type,2,'_'));
format type $mylabel.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Nov 2018 13:14:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combing-names-from-dataset-with-column-names-in-other-dataset/m-p/515079#M138964</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-11-21T13:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: Combing names from dataset with column names in other dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combing-names-from-dataset-with-column-names-in-other-dataset/m-p/515258#M138994</link>
      <description>Sounds like a candidate for a data _null_ step to call execute a proc datasets that will change column names and install those descriptive labels</description>
      <pubDate>Wed, 21 Nov 2018 22:49:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combing-names-from-dataset-with-column-names-in-other-dataset/m-p/515258#M138994</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2018-11-21T22:49:45Z</dc:date>
    </item>
  </channel>
</rss>

