<?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>Thema "Betreff: Mehrfache Werte pro Datensatz" in CoDe SAS German</title>
    <link>https://communities.sas.com/t5/CoDe-SAS-German/Mehrfache-Werte-pro-Datensatz/m-p/759672#M2681</link>
    <description>&lt;P&gt;Hallo Katrin,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;folgender Code sollte funktionieren, geht sicherlich noch eleganter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data in;
infile datalines;
input id $ a $ b $ c $ d $ e $ f $;
datalines;
1 0002 1235 3468 4587 3952 6795
2 0136 5976 3290 0554 4281 3942
3 3594 4381 4753 3954 0002 4753
;
run;

data in2 ;
set in;
if 
a = b or 
a = c or
a = d or
a = e or
a = f or

b = a or 
b = c or
b = d or
b = e or
b = f or 

c = a or 
c = b or
c = d or
c = e or
c = f or 

d = a or 
d = b or
d = c or
d = e or
d = f or 

e = a or 
e = b or
e = c or
e = d or
e = f or 

f = a or 
f = b or
f = c or
f = d or
f = e ;
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Viele Grüße&lt;/P&gt;&lt;P&gt;Bernd&lt;/P&gt;</description>
    <pubDate>Thu, 05 Aug 2021 12:43:55 GMT</pubDate>
    <dc:creator>Spinner_Bernd</dc:creator>
    <dc:date>2021-08-05T12:43:55Z</dc:date>
    <item>
      <title>Mehrfache Werte pro Datensatz</title>
      <link>https://communities.sas.com/t5/CoDe-SAS-German/Mehrfache-Werte-pro-Datensatz/m-p/759668#M2678</link>
      <description>&lt;P&gt;Hallo zusammen,&lt;/P&gt;&lt;P&gt;ich habe eine csv-Datei in SAS importiert, die in der ersten Spalte eine ID enthält und in den restlichen Spalten 4-stellige Zahlen-Codes.&lt;/P&gt;&lt;P&gt;Ich möchte die Datensätze angezeigt bekommen, in denen 4-stellige Zahlen-Codes mehrfach vorkommen.&lt;/P&gt;&lt;P&gt;Beispiel:&lt;/P&gt;&lt;P&gt;1;0002;1235;3468;4587;3952;6795;&lt;/P&gt;&lt;P&gt;2;0136;5976;3290;0554;4281;3942;&lt;/P&gt;&lt;P&gt;3;3594;4381;4753;3954;0002;4753;&lt;/P&gt;&lt;P&gt;Hier sollte mir im Ergebnis nur noch die 3. Zeile angezeigt werden, da diese den zahlen-Code "4753" mehrfach enthält.&lt;/P&gt;&lt;P&gt;Ich habe schon probiert, die Daten erst mit proc transpose zu transponieren. Allerdings komme ich nicht wirklich weiter, weil die Datei über eine Million Datensätze hat.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Vielen Dank vorab und viele Grüße&lt;/P&gt;&lt;P&gt;Katrin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Aug 2021 12:13:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/CoDe-SAS-German/Mehrfache-Werte-pro-Datensatz/m-p/759668#M2678</guid>
      <dc:creator>Katrin11</dc:creator>
      <dc:date>2021-08-05T12:13:20Z</dc:date>
    </item>
    <item>
      <title>Betreff: Mehrfache Werte pro Datensatz</title>
      <link>https://communities.sas.com/t5/CoDe-SAS-German/Mehrfache-Werte-pro-Datensatz/m-p/759669#M2679</link>
      <description>&lt;P&gt;Bitte probier mal das:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines dlm=";";
input (id c1-c6) ($);
datalines4;
1;0002;1235;3468;4587;3952;6795;
2;0136;5976;3290;0554;4281;3942;
3;3594;4381;4753;3954;0002;4753;
;;;;

proc transpose data=have out=long (rename=(col1=code));
by id;
var c:;
run;

data want;
set long;
by id;
retain ind list;
length list $50.;
if first.id
then call missing(ind,list);
if index(list,strip(code)) then ind = 1;
list = catx(";",list,code);
if last.id and ind;
keep id;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Ein transpose wide to long sollte eigentlich kein Problem darstellen.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Aug 2021 12:30:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/CoDe-SAS-German/Mehrfache-Werte-pro-Datensatz/m-p/759669#M2679</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-08-05T12:30:17Z</dc:date>
    </item>
    <item>
      <title>Re: Mehrfache Werte pro Datensatz</title>
      <link>https://communities.sas.com/t5/CoDe-SAS-German/Mehrfache-Werte-pro-Datensatz/m-p/759671#M2680</link>
      <description>&lt;P&gt;Ausnahmsweise mal eine Lösung ohne tranpose:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   length id $ 10 var1-var6 $ 4;
   infile datalines4 delimiter=';';
   input ID var1-var6;
   datalines4;
1;0002;1235;3468;4587;3952;6795
2;0136;5976;3290;0554;4281;3942
3;3594;4381;4753;3954;0002;4753
;;;;


data want;
   set have;

   length alle $ 40;

   array werte var:;

   alle = catx('|', of var:);

   do i = 1 to dim(werte)-1;
      if count(alle, trim(werte[i])) &amp;gt; 1 then do;
         output;
         leave;
      end;
   end;

   drop i alle;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Aug 2021 12:43:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/CoDe-SAS-German/Mehrfache-Werte-pro-Datensatz/m-p/759671#M2680</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-08-05T12:43:01Z</dc:date>
    </item>
    <item>
      <title>Betreff: Mehrfache Werte pro Datensatz</title>
      <link>https://communities.sas.com/t5/CoDe-SAS-German/Mehrfache-Werte-pro-Datensatz/m-p/759672#M2681</link>
      <description>&lt;P&gt;Hallo Katrin,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;folgender Code sollte funktionieren, geht sicherlich noch eleganter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data in;
infile datalines;
input id $ a $ b $ c $ d $ e $ f $;
datalines;
1 0002 1235 3468 4587 3952 6795
2 0136 5976 3290 0554 4281 3942
3 3594 4381 4753 3954 0002 4753
;
run;

data in2 ;
set in;
if 
a = b or 
a = c or
a = d or
a = e or
a = f or

b = a or 
b = c or
b = d or
b = e or
b = f or 

c = a or 
c = b or
c = d or
c = e or
c = f or 

d = a or 
d = b or
d = c or
d = e or
d = f or 

e = a or 
e = b or
e = c or
e = d or
e = f or 

f = a or 
f = b or
f = c or
f = d or
f = e ;
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Viele Grüße&lt;/P&gt;&lt;P&gt;Bernd&lt;/P&gt;</description>
      <pubDate>Thu, 05 Aug 2021 12:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/CoDe-SAS-German/Mehrfache-Werte-pro-Datensatz/m-p/759672#M2681</guid>
      <dc:creator>Spinner_Bernd</dc:creator>
      <dc:date>2021-08-05T12:43:55Z</dc:date>
    </item>
    <item>
      <title>Betreff: Mehrfache Werte pro Datensatz</title>
      <link>https://communities.sas.com/t5/CoDe-SAS-German/Mehrfache-Werte-pro-Datensatz/m-p/759673#M2682</link>
      <description>&lt;P&gt;Hallo&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/268161"&gt;@Katrin11&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;mit einer Perl Regular Expression geht es auch:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards dlm=';';
input ID (code1-code6)(:$4.);
cards4;
1;0002;1235;3468;4587;3952;6795;
2;0136;5976;3290;0554;4281;3942;
3;3594;4381;4753;3954;0002;4753;
;;;;

data want;
set have;
if prxmatch('/(\d{4}).+\1/',catx('#',of code:));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Edit:&lt;/P&gt;
&lt;P&gt;Erläuterung: Die CATX-Funktion verkettet die sechs Codes mit einem beliebig gewählten Trennzeichen, z. B. zu &lt;FONT face="courier new,courier"&gt;3594#4381#4753#3954#0002#4753&lt;/FONT&gt;. Dann sucht die PRXMATCH-Funktion in diesem String nach vier aufeinanderfolgenden Ziffern (dafür steht "&lt;FONT face="courier new,courier"&gt;\d{4}&lt;/FONT&gt;"), nach denen mindestens ein weiteres Zeichen ("&lt;FONT face="courier new,courier"&gt;.+&lt;/FONT&gt;") sowie erneut die zuvor gefundenen vier Ziffern ("&lt;FONT face="courier new,courier"&gt;\1&lt;/FONT&gt;") folgen. Da die Codes alle vierstellig sind, muss es sich bei dem zweiten "Treffer" ggf. um einen wiederholten Code handeln. Der Rückgabewert der PRXMATCH-Funktion ist dann die Zeichenposition des ersten der doppelten Codes, im Beispiel also 11 (allgemein: eine Zahl &amp;gt;0), und der betreffende Satz wird ausgegeben. Tritt kein Code doppelt auf, ist der Rückgabewert 0 und die IF-Bedingung damit nicht erfüllt, so dass der Satz nicht ausgegeben wird.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Aug 2021 13:03:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/CoDe-SAS-German/Mehrfache-Werte-pro-Datensatz/m-p/759673#M2682</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-08-05T13:03:54Z</dc:date>
    </item>
    <item>
      <title>Betreff: Mehrfache Werte pro Datensatz</title>
      <link>https://communities.sas.com/t5/CoDe-SAS-German/Mehrfache-Werte-pro-Datensatz/m-p/759679#M2683</link>
      <description>Vielen Dank, das hat geklappt! Ich musste nur noch einen Zwischenschritt einfügen, weil in meinem Datensatz auch leere Spalten vorkommen können.&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Aug 2021 13:26:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/CoDe-SAS-German/Mehrfache-Werte-pro-Datensatz/m-p/759679#M2683</guid>
      <dc:creator>Katrin11</dc:creator>
      <dc:date>2021-08-05T13:26:44Z</dc:date>
    </item>
  </channel>
</rss>

