Hello,
I have data for cancer with 106 variables including year and brain in CASite67 which has several types of cancer including brain (coded as 1301 and 1302 for insitu and malignant respectively).
if Seer_site_group in ( 31010 ) and beh=2
then CASite67= 3101 ; *Brain, In Situ;
if Seer_site_group in ( 31010 ) and beh=3
then CASite67= 3102 ; *Brain, Malignant;
I need to restrict the data for brain only for years 2004-2013.
Thanks
So we need a little more conditional logic then simple dataset options. This should output records with those two codes occuring in the specified years
data want;
set have;
if CaSite67 in (3101,3102) then do;
if 2004 le year le 2013 then output;
else; /* do nothing for the brain cancer codes*/
end;
else output; /* all the other codes for CaSite67*/
run;
It is not clear if you want to create a new data set or subset for analysis or whether your variable CASite67 exists in your data.
If you need to create a subset data set and that variable is in your existing data then something like this should work:
Data want;
set have (where= (CASite67 in (3101,3102) and (2004 le year le 2013)));
run;
Thank you ballardw.
This statement kept only the brain observations in CASite67. What I needed is to keep all other cancer observations
such as:
if Seer_site_group in ( 20010 )
then CASite67= 101 ; *Lip;
if Seer_site_group in ( 20020 )
then CASite67= 102 ; *Tongue ;
if Seer_site_group in ( 20030 )
then CASite67= 103 ; *Salivary glands;
if Seer_site_group in ( 20040 )
then CASite67= 104 ; *Floor of Mouth;
if Seer_site_group in ( 20050)
then CASite67= 105 ; *Gum and Other Mouth;
if Seer_site_group in ( 20060)
then CASite67= 106 ; *Nasopharynx;
if Seer_site_group in ( 20070 )
then CASite67= 107 ; *Tonsil;
for all years (1999-2013)
and just brain observations from year 2004 to 2013.
Thanks
So we need a little more conditional logic then simple dataset options. This should output records with those two codes occuring in the specified years
data want;
set have;
if CaSite67 in (3101,3102) then do;
if 2004 le year le 2013 then output;
else; /* do nothing for the brain cancer codes*/
end;
else output; /* all the other codes for CaSite67*/
run;
I think this worked just fine. Thank you a lot.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.