<?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 Observation in dataset each row as variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Observation-in-dataset-each-row-as-variable/m-p/697406#M213109</link>
    <description>I have a dataset named table1 with only one column named UU&lt;BR /&gt;&lt;BR /&gt;Column =UU&lt;BR /&gt;L36&lt;BR /&gt;D25&lt;BR /&gt;J01&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Then i have another raw dataset called table2 (with many columns)&lt;BR /&gt;Column1 Column2&lt;BR /&gt;Xxx Xxxx&lt;BR /&gt;U13 Xxxx&lt;BR /&gt;J01 Xxxx&lt;BR /&gt;H56 Xxxx&lt;BR /&gt;L36 Xxxx&lt;BR /&gt;&lt;BR /&gt;I would like to use table2 and table1 to create as following:&lt;BR /&gt;&lt;BR /&gt;Table J01&lt;BR /&gt;Column1 column2&lt;BR /&gt;J01 Xxxxxx&lt;BR /&gt;J01 Xxxxxx&lt;BR /&gt;&lt;BR /&gt;TableL36&lt;BR /&gt;Column1 Column2&lt;BR /&gt;L36 Xxxxx&lt;BR /&gt;L36 Xxxxx&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
    <pubDate>Sun, 08 Nov 2020 06:25:29 GMT</pubDate>
    <dc:creator>someone_new</dc:creator>
    <dc:date>2020-11-08T06:25:29Z</dc:date>
    <item>
      <title>Observation in dataset each row as variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Observation-in-dataset-each-row-as-variable/m-p/697406#M213109</link>
      <description>I have a dataset named table1 with only one column named UU&lt;BR /&gt;&lt;BR /&gt;Column =UU&lt;BR /&gt;L36&lt;BR /&gt;D25&lt;BR /&gt;J01&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Then i have another raw dataset called table2 (with many columns)&lt;BR /&gt;Column1 Column2&lt;BR /&gt;Xxx Xxxx&lt;BR /&gt;U13 Xxxx&lt;BR /&gt;J01 Xxxx&lt;BR /&gt;H56 Xxxx&lt;BR /&gt;L36 Xxxx&lt;BR /&gt;&lt;BR /&gt;I would like to use table2 and table1 to create as following:&lt;BR /&gt;&lt;BR /&gt;Table J01&lt;BR /&gt;Column1 column2&lt;BR /&gt;J01 Xxxxxx&lt;BR /&gt;J01 Xxxxxx&lt;BR /&gt;&lt;BR /&gt;TableL36&lt;BR /&gt;Column1 Column2&lt;BR /&gt;L36 Xxxxx&lt;BR /&gt;L36 Xxxxx&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Sun, 08 Nov 2020 06:25:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Observation-in-dataset-each-row-as-variable/m-p/697406#M213109</guid>
      <dc:creator>someone_new</dc:creator>
      <dc:date>2020-11-08T06:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: Observation in dataset each row as variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Observation-in-dataset-each-row-as-variable/m-p/697409#M213110</link>
      <description>&lt;P&gt;What is the logic here? Why not D25?&lt;/P&gt;</description>
      <pubDate>Sun, 08 Nov 2020 07:06:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Observation-in-dataset-each-row-as-variable/m-p/697409#M213110</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-11-08T07:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: Observation in dataset each row as variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Observation-in-dataset-each-row-as-variable/m-p/697411#M213111</link>
      <description>I forgot to include it sorry</description>
      <pubDate>Sun, 08 Nov 2020 07:10:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Observation-in-dataset-each-row-as-variable/m-p/697411#M213111</guid>
      <dc:creator>someone_new</dc:creator>
      <dc:date>2020-11-08T07:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: Observation in dataset each row as variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Observation-in-dataset-each-row-as-variable/m-p/697412#M213112</link>
      <description>&lt;P&gt;Ok. But you're not interested in&amp;nbsp;&lt;SPAN&gt;U13, correct?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Nov 2020 07:22:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Observation-in-dataset-each-row-as-variable/m-p/697412#M213112</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-11-08T07:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: Observation in dataset each row as variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Observation-in-dataset-each-row-as-variable/m-p/697414#M213113</link>
      <description>&lt;P&gt;Your column2 values in the result do not correspond to those in table2.&lt;/P&gt;
&lt;P&gt;Why do you get 2 observations for each key in the result tables, when there's only one each in table2?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please supply the source data in usable form (data steps with datalines), to remove all doubt about variable attributes and contents, and make the expected result&amp;nbsp;&lt;EM&gt;exactly&lt;/EM&gt; as it would be from those sources.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that splitting up tables like this is in most cases not needed and only hinders further processing. You can always use the keys for BY-group processing from the complete dataset.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Nov 2020 07:31:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Observation-in-dataset-each-row-as-variable/m-p/697414#M213113</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-08T07:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: Observation in dataset each row as variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Observation-in-dataset-each-row-as-variable/m-p/697443#M213131</link>
      <description>&lt;P&gt;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;select distinct count(UU) into : cnt from table1;&lt;BR /&gt;select distinct UU into :var1 - from table1;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;%macro test;&lt;BR /&gt;%do i= 1 %to &amp;amp;cnt;&lt;BR /&gt;data &amp;amp;&amp;amp;var&amp;amp;i;&lt;BR /&gt;set table2;&lt;BR /&gt;where col1= "&amp;amp;&amp;amp;var&amp;amp;i";&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%test;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Nov 2020 16:15:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Observation-in-dataset-each-row-as-variable/m-p/697443#M213131</guid>
      <dc:creator>chaitali9</dc:creator>
      <dc:date>2020-11-08T16:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: Observation in dataset each row as variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Observation-in-dataset-each-row-as-variable/m-p/697449#M213132</link>
      <description>&lt;P&gt;You could use CALL EXECUTE to create each table:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data t1;
input UU $;
datalines;
L36
D25
J01
;

data t2;
input C1 $ C2 $;
datalines;
Xxx Xxxx
U13 Xxxx
J01 Xxxx
H56 Xxxx
L36 Xxxx
;

proc sql;
create view t3 as
select C1 from t2
intersect
select UU from t1;
quit;

data _null_;
set t3;
length command $100;
command = cats("data table", C1, "; set t2; where C1='", C1, "'; run;");
call execute(command);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here is the log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt; 71         
 72         proc sql;
 73         create view t3 as
 74         select C1 from t2
 75         intersect
 76         select UU from t1;
 NOTE: SQL view WORK.T3 a été définie.
 77         quit;
 NOTE: PROCEDURE SQL a utilisé (Durée totale du traitement) :
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 78         
 79         
 80         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 91         
 Soumission : 8 nov. 2020 13:36:21
 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 70         
 71         
 72         data _null_;
 73         set t3;
 74         length command $100;
 75         command = cats("data table", C1, "; set t2; where C1='", C1, "'; run;");
 76         call execute(command);
 77         run;
 
 NOTE: There were 5 observations read from the data set WORK.T2.
 NOTE: There were 3 observations read from the data set WORK.T1.
 NOTE: There were 2 observations read from the data set WORK.T3.
 NOTE: DATA statement a utilisé (Durée totale du traitement) :
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 NOTE: CALL EXECUTE generated line.
 1         + data tableJ01; set t2; where C1='J01'; run;
 
 NOTE: There were 1 observations read from the data set WORK.T2.
       WHERE C1='J01';
 NOTE: The data set WORK.TABLEJ01 has 1 observations and 2 variables.
 NOTE: DATA statement a utilisé (Durée totale du traitement) :
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 2         + data tableL36; set t2; where C1='L36'; run;
 
 NOTE: There were 1 observations read from the data set WORK.T2.
       WHERE C1='L36';
 NOTE: The data set WORK.TABLEL36 has 1 observations and 2 variables.
 NOTE: DATA statement a utilisé (Durée totale du traitement) :
       real time           0.00 seconds
       cpu time            0.01 seconds&lt;/PRE&gt;</description>
      <pubDate>Sun, 08 Nov 2020 18:41:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Observation-in-dataset-each-row-as-variable/m-p/697449#M213132</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-11-08T18:41:52Z</dc:date>
    </item>
  </channel>
</rss>

