Hi,
I am merging shell/dummy dataset with a dataset. How to output only those with data and keep the shell/dummy labels as well?
Hopefully I give you guys enough information
Current output:
Yellow highlight = from table shell w/data (Need to Keep the table lables)
Red X = from table shell w/ No data (need to remove everything)
code:
data all;
merge shell (in=a)
allstats (in=b) ;
by ord1 ord2 ord3;
if a ; /*if b;*/
run;
I might try
data all; merge shell (in=a) allstats (in=b) ; by ord1 ord2 ord3; if first.ord2 or in b; run;
Each variable on your by statement has some associated temporary variables that indicate whether the current record is the first or last of the current value of the variable. You access them by First.variable or Last.variable, note the dot in there. These temporary variables are 1/0 numeric values and SAS treats 1 as true and 0 as false.
It is not clear to me if there are supposed to be two headers at the top or not. You may have to add in a test for the value of: or DESC='Baseline' into the IF.
Even better:
data ALL;
merge SHELL
ALLSTARTS (where=(VAL)) ;
by ORD1 ORD2 ORD3;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.