<?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: Column Transposition if the number of variables is fluctuating or another way to do a transposit in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/575809#M12936</link>
    <description>&lt;P&gt;You will have to provide some example data that the macro isn't capturing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The one thing I can think of is that your text_id field has some values that contain characters that aren't acceptable in SAS variable names. If that is the case, you can just include an extra parameter in the macro call statement, namely convertid=yes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, the following works for me:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  infile datalines missover dlm=',';
  length ID   text_id $12   value $12  details  $12;
  input   ID   text_id $   value $  details  $;
  datalines;
14555, first_name, john
14555, last_name, smith
14555, var1, white
14555, sex, m, male
14555, var3, colt
14555, var3, colt
14555, var3, colt
14555, var 4, hollywood
15555, first_name, Janne
15555, last_name, grey
15555, birht_date, 10091950, 10/9/1950
15555, var1, orange
15555, var1, orange
15555, var1, orange
15555, var1, orange
15555, sex, f, female
15555, var2, Xmen
15555, var5, light*yellow
16666, first_name, bruce
16666, last_name, banner
16666, var1, green
16666, var1, green
16666, var1, green
;

%transpose(data=have, out=need, by=id, var=value, 
   id=text_id, use_varname=no, convertid=yes)


proc format;
  value $sex
  'm'='Male'
  'f'='Female'
  ;

run;

data want(drop=_:);
  set need(rename=(birht_date=_birht_date));
  birth_date=input(_birht_date,mmddyy8.);
  format birth_date date9.;
  format sex $sex.;
run;

proc print data=want;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 23 Jul 2019 14:08:10 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2019-07-23T14:08:10Z</dc:date>
    <item>
      <title>Column Transposition if the number of variables is fluctuating or another way to do a transposition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/574936#M12759</link>
      <description>&lt;P&gt;Hi All.&lt;BR /&gt;&lt;BR /&gt;I would like to perform a transposition&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose
 data = work.have
 out = work.want_t;
var var1, name, home......
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But I found multiple problems:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;entries that have different amount of variables&lt;/LI&gt;&lt;LI&gt;I found errors : variable : not found and variable_name contains more than 32 characters&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;What do you do in this case ? if there is transposition problems.&lt;/P&gt;&lt;P&gt;are there other way to perform a transposition ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;using indexes and adding values in rows&lt;/STRONG&gt; ? &amp;lt; &lt;FONT color="#FF0000"&gt;this could be interesting because the number of columns of the havev dataset that belongs to one entry is too variable.&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;Thank you for response&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 13:19:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/574936#M12759</guid>
      <dc:creator>SIgnificatif</dc:creator>
      <dc:date>2019-07-19T13:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: Column Transposition if the number of variables is fluctuating or another way to do a transposit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/574938#M12761</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/250627"&gt;@SIgnificatif&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi All.&lt;BR /&gt;&lt;BR /&gt;I would like to perform a transposition&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose
 data = work.have
 out = work.want_t;
var var1, name, home......
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But I found multiple problems:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;entries that have different amount of variables&lt;/LI&gt;
&lt;/OL&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What "entries" do you mean? Can you give an example?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;I found errors : variable : not found and variable_name contains more than 32 characters&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So WORK.HAVE has variable names with more than 32 characters? I did not think that was possible. Please explain.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 13:23:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/574938#M12761</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-19T13:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: Column Transposition if the number of variables is fluctuating or another way to do a transposit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/574940#M12762</link>
      <description>&lt;P&gt;Thank you for response&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the entries are included in the columns:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;first_name last_name variable1_belongs_to_that_person&amp;nbsp;variable2_belongs_to_that_person&amp;nbsp;variable3_belongs_to_that_person&amp;nbsp;variable4_belongs_to_that_person and so on then another&amp;nbsp;first_name last_name variable comes in with columns that belongs to this person.. and it's reapeating.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;the number of columns that belongs to subjects differs&lt;/LI&gt;&lt;LI&gt;if there is no transposition way how to transform these columnt into rows ?&amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The idea is to transpose : trasnform columns into rows , to add sens to the data AND perform some basic classification.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regarding 32 characters, i just used the var followed by names of the columns , I believe their number was too long...&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 13:31:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/574940#M12762</guid>
      <dc:creator>SIgnificatif</dc:creator>
      <dc:date>2019-07-19T13:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: Column Transposition if the number of variables is fluctuating or another way to do a transposit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/574943#M12764</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/250627"&gt;@SIgnificatif&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for response&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the entries are included in the columns:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;first_name last_name variable1_belongs_to_that_person&amp;nbsp;variable2_belongs_to_that_person&amp;nbsp;variable3_belongs_to_that_person&amp;nbsp;variable4_belongs_to_that_person and so on then another&amp;nbsp;first_name last_name variable comes in with columns that belongs to this person.. and it's reapeating.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;the number of columns that belongs to subjects differs&lt;/LI&gt;
&lt;/OL&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Again, I'm not understanding. In a SAS data set, each row has the exact same number of columns (although the values in a given column can be missing). Can you show me a small example?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;regarding 32 characters, i just used the var followed by names of the columns , I believe their number was too long...&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Are we talking about variables in SAS data sets here? Can you show me a PROC CONTENTS output showing the variable name with more than 32 characters?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 13:46:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/574943#M12764</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-19T13:46:45Z</dc:date>
    </item>
    <item>
      <title>Re: Column Transposition if the number of variables is fluctuating or another way to do a transposit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/574951#M12765</link>
      <description>&lt;P&gt;Thank you for the response,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;first_name last_name&amp;nbsp;, they are actually in rows format, i would like to transpose them ( sort of order by..)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;sorry about the long variables,&lt;U&gt;&lt;STRONG&gt; it's not the problem right now&lt;/STRONG&gt;&lt;/U&gt;, the problem is if the variables are missing - because &lt;STRONG&gt;I name&lt;/STRONG&gt; all the variables when I try to transpose.&amp;nbsp; (as I told you the number of rows differs based on the variables first_name and last_name&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 14:06:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/574951#M12765</guid>
      <dc:creator>SIgnificatif</dc:creator>
      <dc:date>2019-07-19T14:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: Column Transposition if the number of variables is fluctuating or another way to do a transposit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/574956#M12766</link>
      <description>&lt;P&gt;Show me a small example.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 14:11:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/574956#M12766</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-19T14:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: Column Transposition if the number of variables is fluctuating or another way to do a transposit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/574968#M12767</link>
      <description>&lt;P&gt;Thank you for the precision.&lt;BR /&gt;&lt;BR /&gt;Here is the example,&lt;BR /&gt;&lt;BR /&gt;I would like to use data from table want into new one with this example, in fact it will be more complex, but I'd like to start with simple things &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;As You see the variables that belongs to first Id differs from the second ID...&lt;BR /&gt;Thanks again.&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="want2.jpg" style="width: 562px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/31158i13034533F3D8B142/image-size/large?v=v2&amp;amp;px=999" role="button" title="want2.jpg" alt="want2.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 14:24:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/574968#M12767</guid>
      <dc:creator>SIgnificatif</dc:creator>
      <dc:date>2019-07-19T14:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Column Transposition if the number of variables is fluctuating or another way to do a transposit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/574970#M12768</link>
      <description>&lt;P&gt;What you are showing is the SAS data set you are working with? Or is it an Excel file? Is it just a list that you made up to illustrate the problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 14:28:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/574970#M12768</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-19T14:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: Column Transposition if the number of variables is fluctuating or another way to do a transposit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/574973#M12769</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/250627"&gt;@SIgnificatif&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi All.&lt;BR /&gt;&lt;BR /&gt;I would like to perform a transposition&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose
 data = work.have
 out = work.want_t;
var var1, name, home......
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But I found multiple problems:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;entries that have different amount of variables&lt;/LI&gt;
&lt;LI&gt;I found errors : variable : not found and variable_name contains more than 32 characters&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;What do you do in this case ? if there is transposition problems.&lt;/P&gt;
&lt;P&gt;are there other way to perform a transposition ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;using indexes and adding values in rows&lt;/STRONG&gt; ? &amp;lt; &lt;FONT color="#ff0000"&gt;this could be interesting because the number of columns of the havev dataset that belongs to one entry is too variable.&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;Thank you for response&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think you may be skipping a couple of steps in your description. If you get an error that of variable not found then that implies that you listed a variable in a procedure. Similar that you entered a variable name of more than 32 characters for some reason. So the question is why? A very common cause of this is reliance on Proc Import with unreliable data sources like spreadsheets where people create sheets with changing columns and column headings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you are getting errors with code you should copy the code and the error messages all from the log and paste into a code box on the forum opened with the {I} or the "running man" icon. The code box is important to preserve formatting of the message and the diagnostic elements that SAS often provides. The forum main message windows will reformat text making those diagnostics of limited use.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 14:34:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/574973#M12769</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-07-19T14:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: Column Transposition if the number of variables is fluctuating or another way to do a transposit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/575058#M12785</link>
      <description>&lt;P&gt;Difficult to guess what you are trying to do, but I'll take a stab. If your data looks something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  informat var value $32.;
  input var value;
  cards;
id 1
first_name John
last_name Doe
var1 15
var2 10
var3 5
var4 8
id 2
first_name Mary
last_name Doe
var1 6
var2 20
id 3
first_name Ralph
last_name Doe
var1 7
var2 4
var3 16
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;then I would first use a simple data step to (1) create an id variable and (2) copy it to all records until a new id is found. i.e.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data need;
  set have;
  length id $32;
  retain id;
  if var eq 'id' then id=value;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;then, finally, I'd use the %transpose macro (that you can copy and paste from:&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/A-better-way-to-FLIP-i-e-transpose-make-wide-a-dataset/ta-p/433620?title=A_Better_Way_to_Flip_(Transpose)_a_SAS_Dataset" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/A-better-way-to-FLIP-i-e-transpose-make-wide-a-dataset/ta-p/433620?title=A_Better_Way_to_Flip_(Transpose)_a_SAS_Dataset&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the actual macro call, given the above, would be:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%transpose(data=need, out=want, by=id, autovars=all, 
   id=var, use_varname=no)
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That would create the wide file you described as the one you are seeking.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH,&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 21:06:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/575058#M12785</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2019-07-19T21:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: Column Transposition if the number of variables is fluctuating or another way to do a transposit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/575074#M12789</link>
      <description>&lt;P&gt;It is really hard to program from photographs of data. Sounds like you have this structure.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile cards dsd dlm='|';
  length name $32 value $50 ;
cards;
id|1234
first_name|Joe
last_name|Smith
id|2345
first_name|Sue
last_name|Jones
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The first thing you need to before transposing is a variable that can be used to group the values for the same observation together.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if you data looks like above then the new group starts when NAME='id'.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data step1;
  set have;
  if name='id' then block+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now you can use BLOCK as the BY variable for PROC TRANSPOSE.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=step1 out=want;
  by block;
  id name;
  var value;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;A couple of issues you might have.&lt;/P&gt;
&lt;P&gt;1) The value of NAME is longer than 32 characters.&amp;nbsp; If so then you cannot use it as the name of the new variable.&amp;nbsp; You might be able to use it as the LABEL of the new variable.&lt;/P&gt;
&lt;P&gt;2) You might have more than one value for the same NAME in the same BLOCK.&amp;nbsp; You might set away with use the LET option on PROC TRANSPOSE, but then you will lose some data.&amp;nbsp; You might need to convert your NAME value into unique names. Or break the data into more blocks.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 23:16:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/575074#M12789</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-19T23:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: Column Transposition if the number of variables is fluctuating or another way to do a transposit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/575289#M12828</link>
      <description>&lt;P&gt;Thanks Dear All for your great ideas,&lt;BR /&gt;&lt;BR /&gt;I'm still brainstorming it, will return to you after i've tried some steps.&lt;BR /&gt;&lt;BR /&gt;1) I found that the column data got mixed if a new variable appears ( because of difference of number of variables for different Id's), I'm thinking to create a sort of condition ( but still don"t know how to write the conditions to create an empty record if a variable of one of the ID's is missing.&lt;BR /&gt;&lt;BR /&gt;2) Did not concider if the name could be the same, is this a real concern ? what could be another solution to that ? create temporary variables for first name and last name ? ( maybe I have not understood well this ..)&lt;BR /&gt;&lt;BR /&gt;Thank you and have a wonderful week &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 07:44:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/575289#M12828</guid>
      <dc:creator>SIgnificatif</dc:creator>
      <dc:date>2019-07-22T07:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: Column Transposition if the number of variables is fluctuating or another way to do a transposit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/575298#M12829</link>
      <description>&lt;P&gt;Update.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;My apologies&lt;/STRONG&gt;,&lt;BR /&gt;I havae recreated the table and the results differs from the first post.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is the image of what data I want - the first step ( because i'll have to perform some calculations afterward)&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Thanks for your support&lt;/STRONG&gt;.&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="want3.jpg" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/31184iFB3D3B3577FC3895/image-size/large?v=v2&amp;amp;px=999" role="button" title="want3.jpg" alt="want3.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 08:25:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/575298#M12829</guid>
      <dc:creator>SIgnificatif</dc:creator>
      <dc:date>2019-07-22T08:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: Column Transposition if the number of variables is fluctuating or another way to do a transposit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/575318#M12832</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/250627"&gt;@SIgnificatif&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Update.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;My apologies&lt;/STRONG&gt;,&lt;BR /&gt;I havae recreated the table and the results differs from the first post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here is the image of what data I want - the first step (&lt;FONT color="#FF9900"&gt;&lt;STRONG&gt; because i'll have to perform some calculations afterward)&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Thanks for your support&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The format you have right now is - for many calculations done with procedures - the most useful one. So before wasting time in transposing data, it could be good idea to explain the calculations you have to do, maybe transposing is not necessary at all. The concepts used to work with data are differ between excel and SAS, understanding those differences is the key to create efficient and easy to maintain code.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 10:06:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/575318#M12832</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-07-22T10:06:11Z</dc:date>
    </item>
    <item>
      <title>Re: Column Transposition if the number of variables is fluctuating or another way to do a transposit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/575322#M12833</link>
      <description>&lt;P&gt;Hi, thank for clarification,&lt;/P&gt;&lt;P&gt;I believe that I'll need the transposition ( with the proc or the macro one that is mentioned here thanks to Art , I mean I have to transpose from vertical to horizontal anyway...&lt;/P&gt;&lt;P&gt;there will not be too complicated calculations, I mean something like this:&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="calculated.jpg" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/31185iFA0A7F3DD90F51DF/image-size/large?v=v2&amp;amp;px=999" role="button" title="calculated.jpg" alt="calculated.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 10:51:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/575322#M12833</guid>
      <dc:creator>SIgnificatif</dc:creator>
      <dc:date>2019-07-22T10:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: Column Transposition if the number of variables is fluctuating or another way to do a transposit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/575326#M12834</link>
      <description>&lt;P&gt;It is high-time that you post data in usable form (a data step using datalines statement, NOT an excel-file) and what do expect/need as result.&lt;/P&gt;
&lt;P&gt;For combining var1 with sex transposing is not necessary - it could be done with a data step using BY and RETAIN, but if you need a report in the presented form, then yes, you will have to transpose the data.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 11:16:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/575326#M12834</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-07-22T11:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: Column Transposition if the number of variables is fluctuating or another way to do a transposit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/575395#M12855</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
infile datalines missover;
length ID   text_id $12   value $12  details  $12;
input   ID   text_id $   value $  details  $;
 datalines;
14555 first_name john
14555 last_name smith
14555 var1 white
14555 sex m male
14555 var3 colt
14555 var4 hollywood
15555 first_name Janne
15555 last_name grey
15555 birht_date 10091950 10/9/1950
15555 var1 orange
15555 sex f female
15555 var2 Xmen
16666 first_name bruce
16666 last_name banner
16666 var1 green
;
   run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks forthe clarification, the abovementioned code is the have data.&lt;/P&gt;&lt;P&gt;thanks for your return :&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="want3.jpg" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/31187i628D16B33107FCB6/image-size/large?v=v2&amp;amp;px=999" role="button" title="want3.jpg" alt="want3.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 14:51:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/575395#M12855</guid>
      <dc:creator>SIgnificatif</dc:creator>
      <dc:date>2019-07-22T14:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Column Transposition if the number of variables is fluctuating or another way to do a transposit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/575401#M12857</link>
      <description>&lt;P&gt;So did you run the PROC TRANSPOSE code?&amp;nbsp; What happened?&lt;/P&gt;
&lt;P&gt;Here is code for your posted data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=want ;
  by id ;
  var value;
  id text_id ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;                          first_    last_                                            birht_
Obs     ID      _NAME_     name      name      var1     sex    var3      var4         date      var2

 1     14555    value     john      smith     white      m     colt    hollywood
 2     15555    value     Janne     grey      orange     f                          10091950    Xmen
 3     16666    value     bruce     banner    green&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 14:57:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/575401#M12857</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-22T14:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Column Transposition if the number of variables is fluctuating or another way to do a transposit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/575426#M12860</link>
      <description>&lt;P&gt;One of the main differences between the transpose procedure, and the transpose macro, is that the macro automatically orders numbered lists (like var1-var4) .. regardless of the order in which they appear in the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You initially indicated that ID wasn't on every record, but now you are showing that it is already on each record.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your detail variable looks like it represents the values for a SAS format. If there aren't too many, I'd just create a format (e.g., in your example data, I'd create a format for sex). As for birth_date (or, as you indicated, birht_date), I'd convert it to be a SAS date. However, you'll have to know whether it represents mmddyyyy or ddmmyyyy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the call you'd use if you were going to use the macro:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%transpose(data=have, out=need, by=id, var=value, 
   id=text_id, use_varname=no)


proc format;
  value $sex
  'm'='Male'
  'f'='Female'
  ;

run;

data want(drop=_:);
  set need(rename=(birht_date=_birht_date));
  birth_date=input(_birht_date,mmddyy8.);
  format birth_date date9.;
  format sex $sex.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The final file (i.e., the file called want) would appear as:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.jpg" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/31190i479BE042CF97C0C4/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.jpg" alt="Capture.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 16:00:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/575426#M12860</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2019-07-22T16:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: Column Transposition if the number of variables is fluctuating or another way to do a transposit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/575669#M12901</link>
      <description>&lt;P&gt;Thanks for the reply,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) but this is &lt;U&gt;&lt;STRONG&gt;not working&lt;/STRONG&gt;&lt;/U&gt; because name of the variable:&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;text_id&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;occures twice or more, ex: same subject could have 'color' many times...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Also i'm interested to keep the names of the variables in text_id 1 time only at the top ..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you again&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2019 07:26:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Column-Transposition-if-the-number-of-variables-is-fluctuating/m-p/575669#M12901</guid>
      <dc:creator>SIgnificatif</dc:creator>
      <dc:date>2019-07-23T07:26:35Z</dc:date>
    </item>
  </channel>
</rss>

