<?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: Renaming variables and reduce number of observations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/787000#M251360</link>
    <description>Yes, its really difficult to be steps ahead now &lt;BR /&gt;I have tried to answer specific on Toms questions and really hope this makes more sense now as it seems so difficult . Hoped I could use proc transpose, but haven't seen it beeing used on a serial of variables. &lt;BR /&gt;Will try understand the steps in proc summary</description>
    <pubDate>Tue, 21 Dec 2021 19:11:16 GMT</pubDate>
    <dc:creator>rookie21</dc:creator>
    <dc:date>2021-12-21T19:11:16Z</dc:date>
    <item>
      <title>Renaming variables and reduce number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786943#M251326</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Im attempting to have only one entry point for each operation(variable name: id) in my long dataset. One operation can include information on multiple lines (as for line1 and 2).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now it is in the format:&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="44.44444444444444%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;Operation 1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;Lead 1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;Operation 1&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;Lead 2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="30px"&gt;Operation 2&lt;/TD&gt;
&lt;TD width="25%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="29px"&gt;Operation 3&lt;/TD&gt;
&lt;TD height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like:&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="378px"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="188.469px" height="30px"&gt;Operation 1&lt;/TD&gt;
&lt;TD width="93.75px" height="30px"&gt;Lead 1&lt;/TD&gt;
&lt;TD width="94.7812px" height="30px"&gt;Lead 2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="188.469px" height="30px"&gt;Operation 2&lt;/TD&gt;
&lt;TD width="93.75px" height="30px"&gt;.&lt;/TD&gt;
&lt;TD width="94.7812px" height="30px"&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Operation 3&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;&lt;BR /&gt;Lead_x&amp;nbsp; contains multiple variables (33 variables) which I think should be renamed to move to the corresponding row with a suffix indicating 1,2, etc&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Part of data for one patient (record 15) (not showing all 33 variables corresponding to lead, but some):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
   input record id date record_1 id_1 id_lead type_lead$;
   informat date ddmmyy10. ;
	format date ddmmyy10.;
   datalines;
	15 62 15-09-2003 15 62 84 LVL
	15 62 15-09-2003 15 62 83 HVL
	15 85 20-12-2010 . . . .
	15 13 04-08-2017 . . . . 
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I would like the two first rows to be together as:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;15 62 15-09-2003 15 62 &lt;STRONG&gt;84 LVL 83 HVL&lt;/STRONG&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;so only the new variables are in first row&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I thought some of the code would include if statement,.. something like: if id = id_1 but id_lead is not equal to impl_id&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Want output to be:&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="77.77777777777779%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;&lt;CODE class=" language-sas"&gt;record&lt;/CODE&gt;&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;&lt;CODE class=" language-sas"&gt;id &lt;/CODE&gt;&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;&lt;CODE class=" language-sas"&gt; date&lt;/CODE&gt;&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;&lt;CODE class=" language-sas"&gt;record_1&lt;/CODE&gt;&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;&lt;CODE class=" language-sas"&gt;id_1&lt;/CODE&gt;&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;&lt;CODE class=" language-sas"&gt;id_lead&lt;/CODE&gt;&lt;/TD&gt;
&lt;TD width="5.555555555555555%" height="30px"&gt;&lt;CODE class=" language-sas"&gt; type_lead&lt;/CODE&gt;&lt;/TD&gt;
&lt;TD width="2.7777777777777777%" height="30px"&gt;id_lead_2&lt;/TD&gt;
&lt;TD width="2.7777777777777777%" height="30px"&gt;type_lead_2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;15&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;62&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;15-09-2003&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;15&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;62&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;84&lt;/TD&gt;
&lt;TD width="5.555555555555555%" height="30px"&gt;LVL&amp;nbsp;&lt;/TD&gt;
&lt;TD width="2.7777777777777777%" height="30px"&gt;83&lt;/TD&gt;
&lt;TD width="2.7777777777777777%" height="30px"&gt;HVL&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;15&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;85&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;20-12-2010&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="5.555555555555555%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="2.7777777777777777%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="2.7777777777777777%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;15&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;85&lt;/TD&gt;
&lt;TD width="11.11111111111111%" height="30px"&gt;04-08-2017&lt;/TD&gt;
&lt;TD width="11.11111111111111%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="11.11111111111111%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="11.11111111111111%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="5.555555555555555%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="2.7777777777777777%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="2.7777777777777777%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to rename new variables (id_lead_2 and type_lead_2) and how to change them from one row to the other ..&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As seen the unique variable connecting line 1 and 2 is the id and id_1 which is the same .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope to get some help&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 14:58:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786943#M251326</guid>
      <dc:creator>rookie21</dc:creator>
      <dc:date>2021-12-21T14:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming variables and reduce number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786944#M251327</link>
      <description>&lt;P&gt;I'm going to go off on a tangent, and provide advice. The usual advice is to not convert data sets to wide. This generally is not necessary, and causes subsequent programming to be more difficult. See &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068" target="_self"&gt;Maxim 19&lt;/A&gt;&amp;nbsp;"Long beats Wide".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, I feel compelled to ask ... why do you want a wide data set like this? What can you do with a wide data set that you can't do with a long data set?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 15:03:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786944#M251327</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-12-21T15:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming variables and reduce number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786946#M251328</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; for the nice link . Found the description of long/wide&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this particular dataset the reason is that dates, reason of operation, complications and so on are linked with a unique number between dataset. For instance the date of lead implantation is not in the same dataset. I used proc sql to gather information between different sets.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I get the data from each operation on same line, I (think) its gonna be easier to calculate batery duration and so on&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I still haven't found the correct step to use in SAS language&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 15:36:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786946#M251328</guid>
      <dc:creator>rookie21</dc:creator>
      <dc:date>2021-12-21T15:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming variables and reduce number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786949#M251331</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;In this particular dataset the reason is that dates, reason of operation, complications and so on are linked with a unique number between dataset. For instance the date of lead implantation is not in the same dataset. I used proc sql to gather information between different sets.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;This is fine and makes sense, but it is not what I was asking about. I want to know, once you have this wide data set, what analysis thereafter will you be doing that requires wide rather than long?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 15:39:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786949#M251331</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-12-21T15:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming variables and reduce number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786953#M251334</link>
      <description>&lt;P&gt;Ah,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Im actually not good enough in sas to tell whether specific analysis cant be made in wide vs long.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, what I need to do with the dataset:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- create a new variable which needs informations from the new variables (from the "long" observation line")&lt;/P&gt;
&lt;P&gt;- Use the new variables to divide the patients in operation types and for each type describe the demographics&lt;/P&gt;
&lt;P&gt;- calculate which operation type has the best outcome , and if there is a statistical difference&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 15:48:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786953#M251334</guid>
      <dc:creator>rookie21</dc:creator>
      <dc:date>2021-12-21T15:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming variables and reduce number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786954#M251335</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Use the new variables to divide the patients in operation types and &lt;STRONG&gt;for each type describe the demographics&lt;/STRONG&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This to me screams long data, not wide data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even the merging can be done in the long data form, if I am understanding you properly.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 15:50:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786954#M251335</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-12-21T15:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming variables and reduce number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786957#M251337</link>
      <description>&lt;P&gt;It is not hard to do, but it really seems like a waste of time as the result will be a dataset that is almost impossible to use for anything.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The easiest way to transpose a whole series of variables is to use PROC SUMMARY and the IDGROUP feature.&lt;/P&gt;
&lt;P&gt;You will need to know before calling PROC SUMMARY the maximum number of observations you want to keep.&amp;nbsp; If you don't know you can either just set some value larger than you expect or run a separated step to count the maximum.&amp;nbsp; For this example I will use 5 since I can see you only have 4 observations so 5 will be more than enough.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is your data step cleaned up a little.&amp;nbsp; Do not indent the lines of data, it will make it hard to write the input statement.&amp;nbsp; Do not intend the DATALINES (also known as CARDS) statement as that will just encourage the program editor to indent the lines of data.&amp;nbsp; Do not display dates with MDY or DMY order, that will just confuse 50% of your audience.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
  input record id date record_1 id_1 id_lead type_lead $;
  informat date ddmmyy10. ;
  format date yymmdd10.;
datalines;
15 62 15-09-2003 15 62 84 LVL
15 62 15-09-2003 15 62 83 HVL
15 85 20-12-2010 . . . .
15 13 04-08-2017 . . . . 
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So to transpose with PROC SUMMARY you need some key variable that uniquely identifies the observations you want to combine.&amp;nbsp; So it looks like that is RECORD in this case.&amp;nbsp; The data needs to be grouped by the key variable(s) so you can use a BY statement.&amp;nbsp; If it is grouped, but not actually sorted in ascending or descending order then use the NOTSORTED keyword on the BY statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also need the list of variables you want to take the values of.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=test1 ;
  by record ;
  output out=want(drop=_type_) idgroup(out[5] (id date record_1 id_1 id_lead type_lead)= );
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could also include some other summary statistics if you wanted.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2021-12-21 104941.jpg" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66922iD8362DCCDFEEB2A1/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2021-12-21 104941.jpg" alt="Screenshot 2021-12-21 104941.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 15:50:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786957#M251337</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-21T15:50:44Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming variables and reduce number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786965#M251344</link>
      <description>&lt;P&gt;Ok, since Im still feeling pretty new - can you please explain&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I personally thought it would be easier to calcute the number of operations and leads pr operation, if they were presented wide.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lets say&amp;nbsp;&lt;/P&gt;
&lt;P&gt;patient_1&amp;nbsp; Operation_1 Lead&lt;/P&gt;
&lt;P&gt;patient_1 operation _1 lead&lt;/P&gt;
&lt;P&gt;How can I get SAS to "count" them ( I have a unique lead-nr) in long dataset ?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 16:08:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786965#M251344</guid>
      <dc:creator>rookie21</dc:creator>
      <dc:date>2021-12-21T16:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming variables and reduce number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786966#M251345</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/404450"&gt;@rookie21&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Ok, since Im still feeling pretty new - can you please explain&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I personally thought it would be easier to calcute the number of operations and leads pr operation, if they were presented wide.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lets say&amp;nbsp;&lt;/P&gt;
&lt;P&gt;patient_1&amp;nbsp; Operation_1 Lead&lt;/P&gt;
&lt;P&gt;patient_1 operation _1 lead&lt;/P&gt;
&lt;P&gt;How can I get SAS to "count" them ( I have a unique lead-nr) in long dataset ?&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I am not grasping the meaning of your question here. Make it more specific and concrete.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 16:10:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786966#M251345</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-12-21T16:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming variables and reduce number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786967#M251346</link>
      <description>&lt;P&gt;What do you want to count?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If PATIENT is the variable with the patient identifier and OPERATION is the variable that identifies the operation type then you can count how many times each patient had each operation type with a simple PROC FREQ.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq;
  tables patient*operation / list;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you need something more exotic you might need to do some pre-processing or perhaps use PROC SQL.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 16:12:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786967#M251346</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-21T16:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming variables and reduce number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786972#M251347</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp; Can see&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;replied to my question with the proc freq step &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried this code as you wrote&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=test1 ;
&lt;STRONG&gt;  by record ;&lt;/STRONG&gt;
  output out=want(drop=_type_) idgroup(out[5] (id date record_1 id_1 id_lead type_lead)= );
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This collects all data on one line (everything for that patient) instead of for each operation.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I tried the same step with id:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=test1; 
by id; run; 

proc summary data=test1 ;
  by id ;
  output out=want(drop=_type_) idgroup(out[5] (id date record_1 id_1 id_lead type_lead)= );
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and got (showing part of output)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rookie21_0-1640103789539.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66924i494724AB26ED5013/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rookie21_0-1640103789539.png" alt="rookie21_0-1640103789539.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Here it is asuming 5 of every variable . Is it not possible to have&amp;nbsp;&lt;CODE class=" language-sas"&gt;id date record_1 id_1&lt;/CODE&gt;&amp;nbsp;only once, while the unique data for the additional lead (id_lead and type_lead) is folded out with 5 repeated events ?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried deleting&amp;nbsp;&lt;CODE class=" language-sas"&gt;id date record_1 id_1&lt;/CODE&gt;&amp;nbsp;in the parentes, but that solely took out those data in the out put&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 16:28:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786972#M251347</guid>
      <dc:creator>rookie21</dc:creator>
      <dc:date>2021-12-21T16:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming variables and reduce number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786977#M251349</link>
      <description>&lt;P&gt;You need to understand how your data is organized.&lt;/P&gt;
&lt;P&gt;What are the variables that uniquely identify the observations you want to treat as a single group?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What does RECORD mean?&amp;nbsp; Is that the patient identifier?&lt;/P&gt;
&lt;P&gt;What does ID mean? Is that the operation identifier?&amp;nbsp; Can the same ID be used by multiple patients? That doesn't seem plausible if it is an identifier of a particular operation.&amp;nbsp; But if it is instead a classification of an operation (Hernia operation versus Open Heart Surgery) then it will not be unique.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is the goal to get one record per patient per operation?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then it sounds like your should use both variables in the BY statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if the ID is a "type of operation" field then you might also need some other variable to uniquely identify the group.&amp;nbsp; It is possible to multiple operations on your knee for example.&amp;nbsp; So perhaps you need to include the DATE also?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=test1 ;
  by record id date;
  output out=want(drop=_type_) idgroup(out[5] (record_1 id_1 id_lead type_lead)= );
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 16:53:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786977#M251349</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-21T16:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming variables and reduce number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786981#M251351</link>
      <description>&lt;P&gt;Agreeing with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I realize that figuring out the best layout for data, and the best way to proceed with analysis, is something that beginners cannot know (even experienced people struggle with this). This is why I am trying to steer you into what seems to be a better approach&amp;nbsp;(and I assume the same is true for Tom).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But we can't know your data as well as you know it. Maxim 3, you know. So a combination of experienced SAS programmers and your knowledge of the data would be a very good combination. But we need you to explain in more detail what the data is, and more detail about what analysis will be done.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 17:06:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786981#M251351</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-12-21T17:06:48Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming variables and reduce number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786998#M251359</link>
      <description>Yes, &lt;BR /&gt;Record is patient identifier. &lt;BR /&gt;ID is operation identifier. The information in ID is equal to ID_1. &lt;BR /&gt;ID is unique for each operation and is therefore not shared between patients. ID is not "type" of operation. &lt;BR /&gt;The serial of information I would like to transpose as one is id_lead and type_lead. &lt;BR /&gt;&lt;BR /&gt;The goal is to in the end to get on record pr patient - but first as you write: one record per patient per operation?&lt;BR /&gt;&lt;BR /&gt;Does it make better sense now ? &lt;BR /&gt;</description>
      <pubDate>Tue, 21 Dec 2021 19:04:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/786998#M251359</guid>
      <dc:creator>rookie21</dc:creator>
      <dc:date>2021-12-21T19:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming variables and reduce number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/787000#M251360</link>
      <description>Yes, its really difficult to be steps ahead now &lt;BR /&gt;I have tried to answer specific on Toms questions and really hope this makes more sense now as it seems so difficult . Hoped I could use proc transpose, but haven't seen it beeing used on a serial of variables. &lt;BR /&gt;Will try understand the steps in proc summary</description>
      <pubDate>Tue, 21 Dec 2021 19:11:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/787000#M251360</guid>
      <dc:creator>rookie21</dc:creator>
      <dc:date>2021-12-21T19:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming variables and reduce number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/787008#M251368</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/404450"&gt;@rookie21&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BR /&gt;The goal is to in the end to get on record pr patient - but first as you write: one record per patient per operation?&lt;BR /&gt;&lt;BR /&gt;Does it make better sense now ? &lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes it makes better sense now. But I would probably go for one record per patient per operation, rather than a wide record with one patient and multiple operations. Perhaps as you move forward on this project, it will become more clear why we are recommending it this way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To me, the "goal" is really to achieve some sort of meaningful analysis of the data. So, when you say the goal is a particular data layout (one record per patient, or one record per patient per operation), that is really a step along the way, not the goal. And depending on whether or not you take the proper steps along the way, you will have an easy path or a much more difficult path.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 20:03:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/787008#M251368</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-12-21T20:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming variables and reduce number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/787016#M251372</link>
      <description>&lt;P&gt;Can each operation have multiple "leads"?&amp;nbsp; What does "lead" mean?&amp;nbsp; Are you collecting electrocardiograms during the operation?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Dec 2021 21:19:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/787016#M251372</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-21T21:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming variables and reduce number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/787095#M251416</link>
      <description>&lt;P&gt;I am keeping it one record pr operation pr patient for now.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Truthfully thankful for the job u guys are doing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hopefully I'll get a better sense of when to do what with more experience&lt;/P&gt;
&lt;P&gt;Each step right now is like a milestone, so thats a goal in itself. Getting to understand that these are just some groundwork before the real analysis starts&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again for all the help !&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Dec 2021 13:15:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/787095#M251416</guid>
      <dc:creator>rookie21</dc:creator>
      <dc:date>2021-12-22T13:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: Renaming variables and reduce number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/787097#M251418</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Can each operation have multiple "leads"?&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;- Yes, each operation can have up till 3 leads&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What does "lead" mean?&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Are you collecting electrocardiograms during the operation?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;No, not electrocardiograms. &lt;/SPAN&gt;&lt;SPAN&gt;Its implantation of heart devices. And leads are those wires which are put in the body. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So if I divide the variables into 4 levels. I have:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;- a patient identifier: record&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;- operation information: id (unique for each operation) date (operation date)&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;- battery information: record_1 (actually copied from record), id_1 (copied from id above)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;- lead/wire information: id_lead (unique for each implanted wire) and type_lead&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Now I got the data to include one record pr operation pr patient. As the data was pivoted in three "extra" levels, I got a total of more than 500 variables.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I've used a datastep to clean it up a bit by using keep and drop statements.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Im doing some more coding to classify what happens at each operation.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;After that I shall present my data with only one record pr patient in the study group.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Think I can use:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data = want;
	by record ;
	output out=one_line_pr_patient (drop=_type_) idgroup(out[1] ( id_1 -- type_lead_3 ) =); 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;and then again clean it up a bit, so the variables with same contents is dropped.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Or is there a more "correct"&amp;nbsp; way of specifing earlyer with variables (the string of lead information) that can get pivoted&amp;nbsp; ?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Dec 2021 13:43:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Renaming-variables-and-reduce-number-of-observations/m-p/787097#M251418</guid>
      <dc:creator>rookie21</dc:creator>
      <dc:date>2021-12-22T13:43:18Z</dc:date>
    </item>
  </channel>
</rss>

