<?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 Identify and change name of a variable in many different dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identify-and-change-name-of-a-variable-in-many-different-dataset/m-p/496866#M131527</link>
    <description>&lt;P&gt;Dear Experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I´m Walking my first steps with SAS and I Need some help.&lt;/P&gt;&lt;P&gt;I have about 100 dataset that&amp;nbsp;look 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="Unbenannt.png" style="width: 455px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23371i6D170D66032EC67B/image-dimensions/455x365?v=v2" width="455" height="365" role="button" title="Unbenannt.png" alt="Unbenannt.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are five different values for each dataset for the variable "Durchgang". In this case you can see two of them (112500, 121000). These numbers are different for every dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I would like to do is to&amp;nbsp;write a Programm that identify these different values in every dataset and sobstitute them with the values 1, 2, 3, 4 and&amp;nbsp;5. So:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;112500 -&amp;gt; 1&lt;/P&gt;&lt;P&gt;121000 -&amp;gt; 2&lt;/P&gt;&lt;P&gt;123040 -&amp;gt; 3&lt;/P&gt;&lt;P&gt;etc...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Version 9.4)&lt;/P&gt;</description>
    <pubDate>Wed, 19 Sep 2018 09:11:59 GMT</pubDate>
    <dc:creator>riccardo88</dc:creator>
    <dc:date>2018-09-19T09:11:59Z</dc:date>
    <item>
      <title>Identify and change name of a variable in many different dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-and-change-name-of-a-variable-in-many-different-dataset/m-p/496866#M131527</link>
      <description>&lt;P&gt;Dear Experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I´m Walking my first steps with SAS and I Need some help.&lt;/P&gt;&lt;P&gt;I have about 100 dataset that&amp;nbsp;look 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="Unbenannt.png" style="width: 455px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23371i6D170D66032EC67B/image-dimensions/455x365?v=v2" width="455" height="365" role="button" title="Unbenannt.png" alt="Unbenannt.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are five different values for each dataset for the variable "Durchgang". In this case you can see two of them (112500, 121000). These numbers are different for every dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I would like to do is to&amp;nbsp;write a Programm that identify these different values in every dataset and sobstitute them with the values 1, 2, 3, 4 and&amp;nbsp;5. So:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;112500 -&amp;gt; 1&lt;/P&gt;&lt;P&gt;121000 -&amp;gt; 2&lt;/P&gt;&lt;P&gt;123040 -&amp;gt; 3&lt;/P&gt;&lt;P&gt;etc...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Version 9.4)&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 09:11:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-and-change-name-of-a-variable-in-many-different-dataset/m-p/496866#M131527</guid>
      <dc:creator>riccardo88</dc:creator>
      <dc:date>2018-09-19T09:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: Identify and change name of a variable in many different dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-and-change-name-of-a-variable-in-many-different-dataset/m-p/496869#M131529</link>
      <description>&lt;P&gt;As with all these questions which concern data which has been split up, putting same data together eradicates the problem:&lt;/P&gt;
&lt;PRE&gt;data want;
  set tmp3.out_auf_: indsname=tmp;
  length dsname $200;
  dsname=tmp;
  if durchgang=112500 then durchgang=1;
  if durchgang=121000 then durchgang=2;
  if durchgang=123040 then durchgang=3;
run;&lt;/PRE&gt;
&lt;P&gt;This takes all datasets from library tmp3 which have the prefix out_auf_, sets them all together, and creates a variable which is the name of the incoming dataset (in case you need to split the data later on).&amp;nbsp; You can then work with the one dataset and vastly simplify your coding and processing, avoiding messy code generation, macro etc.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 09:36:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-and-change-name-of-a-variable-in-many-different-dataset/m-p/496869#M131529</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-19T09:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: Identify and change name of a variable in many different dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-and-change-name-of-a-variable-in-many-different-dataset/m-p/496872#M131532</link>
      <description>&lt;P&gt;Dear RW9,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your answer!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also think&amp;nbsp;creating&amp;nbsp;a single dataset makes a lot of sense.&lt;/P&gt;&lt;P&gt;The Problem is that those number are different for different datasets...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So&amp;nbsp;for the first one I&amp;nbsp;want to assign:&lt;/P&gt;&lt;P&gt;112500 -&amp;gt; 1&lt;/P&gt;&lt;P&gt;121000 -&amp;gt; 2&lt;/P&gt;&lt;P&gt;123040 -&amp;gt; 3&lt;/P&gt;&lt;P&gt;etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second one&amp;nbsp;may be:&lt;/P&gt;&lt;P&gt;109389 -&amp;gt; 1&lt;/P&gt;&lt;P&gt;182937 -&amp;gt; 2&lt;/P&gt;&lt;P&gt;100703 -&amp;gt; 3&lt;/P&gt;&lt;P&gt;etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And so on for onehundred times.&lt;/P&gt;&lt;P&gt;Is there a simple way to automatize this process?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 09:46:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-and-change-name-of-a-variable-in-many-different-dataset/m-p/496872#M131532</guid>
      <dc:creator>riccardo88</dc:creator>
      <dc:date>2018-09-19T09:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Identify and change name of a variable in many different dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-and-change-name-of-a-variable-in-many-different-dataset/m-p/496874#M131533</link>
      <description>&lt;P&gt;You would have to give me some logical reason why those are being changed?&amp;nbsp; Is this decode information in a dataset, is it logically deduced maybe from position in dataset or some other variable.&amp;nbsp; Just saying that some values which are not the same in any dataset need to be changed, I am afraid is not enough information to program anything.&amp;nbsp; Need rules.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 09:51:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-and-change-name-of-a-variable-in-many-different-dataset/m-p/496874#M131533</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-19T09:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: Identify and change name of a variable in many different dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-and-change-name-of-a-variable-in-many-different-dataset/m-p/496883#M131535</link>
      <description>&lt;P&gt;The electroencephalography device&amp;nbsp;Attributes to every recording session a number (e.g 120500).&lt;/P&gt;&lt;P&gt;I have a dataset for every Person that did the&amp;nbsp;Experiment with 5 different recording session, each one identified by a different number.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To compare different Experiment subject I would like the first session of every Experiment subject to be identified by the same number, 1.&lt;/P&gt;&lt;P&gt;The second session to be identified by 2, the third by 3 and so on....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so after that I can for example measure the mean of a value for ALL the Experiment subjects during the same session.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 10:01:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-and-change-name-of-a-variable-in-many-different-dataset/m-p/496883#M131535</guid>
      <dc:creator>riccardo88</dc:creator>
      <dc:date>2018-09-19T10:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: Identify and change name of a variable in many different dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-and-change-name-of-a-variable-in-many-different-dataset/m-p/496885#M131536</link>
      <description>&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;data want;
  set tmp3.out_auf_: indsname=tmp;
  length dsname $200;
  dsname=tmp;
run;

data want;
  set want;
  by dsname durchgang;&lt;BR /&gt;  retain cnt;&lt;BR /&gt;  if first.dsname then cnt=0;&lt;BR /&gt;  if first.durchgang then cnt=cnt+1;&lt;BR /&gt;  if cnt &amp;lt;= 5 then durchgang=cnt;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;I don't have any test data, but something like that should work, basically cnt is incremented each time for a new durchgang, and the first five per file are renamed to the count.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 10:11:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-and-change-name-of-a-variable-in-many-different-dataset/m-p/496885#M131536</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-19T10:11:10Z</dc:date>
    </item>
    <item>
      <title>Re: Identify and change name of a variable in many different dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-and-change-name-of-a-variable-in-many-different-dataset/m-p/496928#M131547</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Thank you very much! This works although incompletely.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Í'm probably doing something wrong.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;My code:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;CODE class=" language-sas"&gt;data try;
  set tmp3.out_auf_: indsname=tmp;
  length dsname $200;
  dsname=tmp;
run;

data try_2;
  set try;
  by dsname Durchgang;
  retain cnt;
  if first.dsname then cnt=0;
  if first.durchgang then cnt=cnt+1;
  if cnt &amp;lt;= 5 then durchgang=cnt;
run;&lt;/CODE&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my LOG (for the second datastep):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;61   data try_2;
62     set try;
63     by dsname Durchgang;
64     retain cnt;
65     if first.dsname then cnt=0;
66     if first.durchgang then cnt=cnt+1;
67     if cnt &amp;lt;= 5 then durchgang=cnt;
68   run;

NOTE: Numeric values have been converted to character values at the places given by:
      (Line):(Column).
      67:30
ERROR: BY variables are not properly sorted on data set WORK.TRY.
Durchgang=122900 VPNummer=100 Signalname=C4-A1 Date=2017/11/17 Time=12:35:04 FFT=1 Hz0_5=33.356
Hz1_0=31.843 Hz1_5=0.041 Hz2_0=6.043 Hz2_5=1.812 Hz3_0=4.102 Hz3_5=0.831 Hz4_0=6.459 Hz4_5=3.986
Hz5_0=1.192 Hz5_5=2.506 Hz6_0=0.76 Hz6_5=1.469 Hz7_0=1.388 Hz7_5=2.092 Hz8_0=3.081 Hz8_5=1.694
Hz9_0=2.093 Hz9_5=0.202 Hz10_0=0.863 Hz10_5=0.545 Hz11_0=0.242 Hz11_5=1.025 Hz12_0=0.625
Hz12_5=0.467 Hz13_0=0.136 Hz13_5=0.6 Hz14_0=0.452 Hz14_5=0.543 Hz15_0=1.699 Hz15_5=1.601
Hz16_0=0.899 Hz16_5=1.493 Hz17_0=1.723 Hz17_5=1.788 Hz18_0=1.611 Hz18_5=0.182 Hz19_0=0.11
Hz19_5=0.662 Hz20_0=0.969 Hz20_5=1.239 Hz21_0=1.353 Hz21_5=1.04 Hz22_0=0.292 Hz22_5=0.007
Hz23_0=0.102 Hz23_5=0.217 Hz24_0=0.641 Hz24_5=0.533 Hz25_0=0.304 new_time=12:35:04
starting_time_1=36372 starting_time_2=38772 starting_time_3=41354 starting_time_4=45124
starting_time_5=48064 dsname=TMP3.OUT_AUF_100_C4A1 FIRST.dsname=0 LAST.dsname=0 FIRST.Durchgang=0
LAST.Durchgang=0 cnt=4 _ERROR_=1 _N_=318
NOTE: The SAS System stopped processing this step because of errors.
NOTE: There were 319 observations read from the data set WORK.TRY.
WARNING: The data set WORK.TRY_2 may be incomplete.  When this step was stopped there were 317
         observations and 64 variables.
WARNING: Datei WORK.TRY_2 wurde nicht ersetzt. Grund: da dieser Schritt angehalten wurde.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.04 seconds

&lt;/PRE&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;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 12:36:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-and-change-name-of-a-variable-in-many-different-dataset/m-p/496928#M131547</guid>
      <dc:creator>riccardo88</dc:creator>
      <dc:date>2018-09-19T12:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: Identify and change name of a variable in many different dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-and-change-name-of-a-variable-in-many-different-dataset/m-p/496935#M131549</link>
      <description>&lt;P&gt;For the by group do:&lt;/P&gt;
&lt;PRE&gt;by dsname Durchgang notsorted;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Sep 2018 12:48:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-and-change-name-of-a-variable-in-many-different-dataset/m-p/496935#M131549</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-19T12:48:46Z</dc:date>
    </item>
    <item>
      <title>Re: Identify and change name of a variable in many different dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identify-and-change-name-of-a-variable-in-many-different-dataset/m-p/496946#M131556</link>
      <description>&lt;P&gt;Oh Maaaan, you are good!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you a lot!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 12:59:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identify-and-change-name-of-a-variable-in-many-different-dataset/m-p/496946#M131556</guid>
      <dc:creator>riccardo88</dc:creator>
      <dc:date>2018-09-19T12:59:29Z</dc:date>
    </item>
  </channel>
</rss>

