<?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: How to get at least one obs  when there are no matching values in the dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-at-least-one-obs-when-there-are-no-matching-values-in/m-p/454336#M114831</link>
    <description>&lt;P&gt;Then can't you just exclude that record from you final datastep? e.g.:&lt;/P&gt;
&lt;PRE&gt;proc transpose data=six out=seven(where=(not missing(id)) drop=_:);
    by id;
    id paramcd;
    var adt;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 16 Apr 2018 03:12:40 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2018-04-16T03:12:40Z</dc:date>
    <item>
      <title>How to get at least one obs  when there are no matching values in the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-at-least-one-obs-when-there-are-no-matching-values-in/m-p/454304#M114814</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The below code produces output :&lt;/P&gt;
&lt;P&gt;adt&amp;nbsp; &amp;nbsp; &amp;nbsp;dom&amp;nbsp; &amp;nbsp;var&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; paramcv&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp;AA&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ADT&amp;nbsp; &amp;nbsp; ARDT&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; BB&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; BDT&amp;nbsp; &amp;nbsp; BRDT&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;OUTPUT NEED in dataset five::&lt;/P&gt;
&lt;P&gt;in data set four there are no OBS . When i used dataset four along with two and three to create five i got the above output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I need:&lt;/P&gt;
&lt;P&gt;adt&amp;nbsp; &amp;nbsp; &amp;nbsp;dom&amp;nbsp; &amp;nbsp;var&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; paramcv&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp;AA&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ADT&amp;nbsp; &amp;nbsp; ARDT&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; BB&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; BDT&amp;nbsp; &amp;nbsp; BRDT&lt;/P&gt;
&lt;P&gt;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; EE&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;EDT&amp;nbsp; &amp;nbsp; &amp;nbsp;ERDT&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help. Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;BR /&gt;&lt;BR /&gt;data one;
input a $ b c;
datalines;
aa 2 3
bb 1 3
cc 4 4
dd 5 6
;

data two(keep=adt dom var paramcd);
set one(where =(a='aa'));
adt=b;
dom="AA";
var="ADTC";
paramcd="ARDT"
;
run;
data three(keep=adt dom var paramcd);
set one(where =(a='bb'));
adt=b;
dom="BB";
var="BDTC";
paramcd="BRDT"
;
run;
data four(keep=adt dom var paramcd);
set one(where =(a='ee'));
adt=b;
dom="ee";
var="EDTC";
paramcd="ERDT"
;
run;

data five;
set two three four;
run;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Apr 2018 21:42:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-at-least-one-obs-when-there-are-no-matching-values-in/m-p/454304#M114814</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2018-04-15T21:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to get at least one obs  when there are no matching values in the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-at-least-one-obs-when-there-are-no-matching-values-in/m-p/454306#M114815</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input a $ b c;
datalines;
aa 2 3
bb 1 3
cc 4 4
dd 5 6
;

data two(keep=adt dom var paramcd);
set one(where =(a='aa'));
adt=b;
dom="AA";
var="ADTC";
paramcd="ARDT"
;
run;
data three(keep=adt dom var paramcd);
set one(where =(a='bb'));
adt=b;
dom="BB";
var="BDTC";
paramcd="BRDT"
;
run;
data four(keep=adt dom var paramcd);
set one end=last;
retain f;
if a='ee' then do;
adt=b;
dom="ee";
var="EDTC";
paramcd="ERDT";
f=1;
end;
if last and not f then do;
adt=.;
dom="ee";
var="EDTC";
paramcd="ERDT";
output;
end;
run;

data five;
set two three four;
run; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 15 Apr 2018 22:03:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-at-least-one-obs-when-there-are-no-matching-values-in/m-p/454306#M114815</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-04-15T22:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to get at least one obs  when there are no matching values in the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-at-least-one-obs-when-there-are-no-matching-values-in/m-p/454308#M114816</link>
      <description>&lt;P&gt;Here's how I would modify your DATA FOUR step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data four(keep=adt dom var paramcd);&lt;BR /&gt;if _n_=1 and done then output;
set one(where =(a='ee')) end=done;
adt=b;
retain dom "EE"
var "EDTC"
paramcd "ERDT"
;&lt;BR /&gt;output;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I assume you meant to get "EE" rather than "ee".&amp;nbsp; But that's easy to change if it was not your intent.&lt;/P&gt;</description>
      <pubDate>Sun, 15 Apr 2018 22:33:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-at-least-one-obs-when-there-are-no-matching-values-in/m-p/454308#M114816</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-04-15T22:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to get at least one obs  when there are no matching values in the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-at-least-one-obs-when-there-are-no-matching-values-in/m-p/454327#M114826</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for the help.&amp;nbsp; But I have one more question. The output in the data set seven from my code is:&lt;/P&gt;
&lt;P&gt;id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ardt&amp;nbsp; &amp;nbsp; &amp;nbsp;brdt&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But as per my specs i have to write to code like this on data set seven.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data eight;&lt;/P&gt;
&lt;P&gt;set seven;&lt;/P&gt;
&lt;P&gt;if erdt is ne . and ardt ne . and brdt ne .then want=min(erdt,ardt,brdt);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because the dataset four did not have any OBS, I am not getting the variable erdt in the&amp;nbsp; dataset seven after proc transpose.&amp;nbsp; Could please help how to approach in this case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output that i need after final step is so i can use my specs code With my code the&amp;nbsp; erdt variable not available&amp;nbsp; in dataset seven. Thank you&lt;/P&gt;
&lt;P&gt;id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ardt&amp;nbsp; &amp;nbsp; &amp;nbsp;brdt&amp;nbsp; &amp;nbsp; erdt&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input id a $ b c;
datalines;
1 aa 2 3
2 bb 1 3
3 cc 4 4
4 dd 5 6
;

data two(keep=id adt dom var paramcd);
set one(where =(a='aa'));
adt=b;
dom="AA";
var="ADTC";
paramcd="ARDT"
;
run;
data three(keep=id adt dom var paramcd);
set one(where =(a='bb'));
adt=b;
dom="bb";
var="BDTC";
paramcd="BRDT"
;
run;
data four(keep=id adt dom var paramcd);
set one(where =(a='ee'));
adt=b;
dom="ee";
var="EDTC";
paramcd="ERDT"
;
run;

data five;
set two three four;
run;

data sl;
input id tr$ ag se$;
datalines;
1 p 23 m
2 o 45 f
3 i 34 m
4 u 53 f
5 y 33 m
;
proc sort data=five;
by id;
run;
proc sort data=sl;
by id;
run;
data six;
merge sl(in=a) five(in=b);
by id;
if b;
run;
proc transpose data=six out=seven(drop=_name_ _label_);
	by id;
	id paramcd;
	var adt;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2018 00:43:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-at-least-one-obs-when-there-are-no-matching-values-in/m-p/454327#M114826</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2018-04-16T00:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to get at least one obs  when there are no matching values in the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-at-least-one-obs-when-there-are-no-matching-values-in/m-p/454331#M114827</link>
      <description>&lt;P&gt;A key part of the reason is that you are using your original code to create data set FOUR.&amp;nbsp; You didn't replace that step with the suggested code.&amp;nbsp; If you fix your original problem, the results will change.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2018 01:51:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-at-least-one-obs-when-there-are-no-matching-values-in/m-p/454331#M114827</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-04-16T01:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to get at least one obs  when there are no matching values in the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-at-least-one-obs-when-there-are-no-matching-values-in/m-p/454333#M114829</link>
      <description>&lt;P&gt;Thank you very much for the reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With your suggested code I am getting the output where the first obs is (id=dot.). I need output without first obs&amp;nbsp;( without id=dot)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ardt&amp;nbsp; &amp;nbsp; &amp;nbsp;brdt&amp;nbsp; &amp;nbsp; erdt&amp;nbsp;&lt;/P&gt;
&lt;P&gt;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output need;&lt;/P&gt;
&lt;P&gt;id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ardt&amp;nbsp; &amp;nbsp; &amp;nbsp;brdt&amp;nbsp; &amp;nbsp; erdt&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2018 02:28:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-at-least-one-obs-when-there-are-no-matching-values-in/m-p/454333#M114829</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2018-04-16T02:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to get at least one obs  when there are no matching values in the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-at-least-one-obs-when-there-are-no-matching-values-in/m-p/454336#M114831</link>
      <description>&lt;P&gt;Then can't you just exclude that record from you final datastep? e.g.:&lt;/P&gt;
&lt;PRE&gt;proc transpose data=six out=seven(where=(not missing(id)) drop=_:);
    by id;
    id paramcd;
    var adt;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2018 03:12:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-at-least-one-obs-when-there-are-no-matching-values-in/m-p/454336#M114831</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-04-16T03:12:40Z</dc:date>
    </item>
  </channel>
</rss>

