Hello,
I'm trying to select all observations where flag is not equal to 'Y' in the previously and set those to Y in the current data pull. It felt like a simple logic, but I don't seem to be getting the right answer. Appreciate the help in helping me understand what am I doing wrong here.
Input data provided in code.
Expected output:
Output received:
my code
data dat1;
input id $ flag $ new zz;
cards;
a Y 12 111
b 22 222
c 33 333
;
run;
proc sql;
create table pilot as
select *, 'Y' as flag
from dat1
where flag neq 'Y';
quit;
data dat1;
input id $ flag $ new zz;
cards;
a Y 12 111
b . 22 222/*see the correction for period in place of missing values*/
c . 33 333/*see the correction for period in place of missing values*/
;
run;
proc sql;
create table pilot as
select id, 'Y' as flag,new ,zz
from dat1
where flag ne 'Y';
quit;
data dat1;
input id $ flag $ new zz;
cards;
a Y 12 111
b . 22 222/*see the correction for period in place of missing values*/
c . 33 333/*see the correction for period in place of missing values*/
;
run;
proc sql;
create table pilot as
select id, 'Y' as flag,new ,zz
from dat1
where flag ne 'Y';
quit;
Those values before being read are "RAW" data and not a SAS data set value. basically to read raw data instream with a list input you would need to have periods in punch raw cards data.
PS Your definition holds true for default missing values in a dataset
The thread could lead to discussion about "how to read raw data" which is out of scope for the stated objective, but I recommend reading those concepts.
You could read the same data as- is with a formatted input to see the difference
data dat1;
input id $ @3 flag $1. new zz;
cards;
a Y 12 111
b 22 222
c 33 333
;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.