BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mayasak
Quartz | Level 8

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

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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;

View solution in original post

5 REPLIES 5
ballardw
Super User

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;

mayasak
Quartz | Level 8

Thank you .

 

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

 

ballardw
Super User

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;

mayasak
Quartz | Level 8

I think this worked just fine. Thank you a lot.

 

AnnaBrown
Community Manager

Great, I'm glad the solution worked for you, mayasak! Can you unmark your response and mark the appropriate "solution" from 

 


Join us for SAS Community Trivia
SAS Bowl XXIX, The SAS Hackathon
Wednesday, March 8, 2023, at 10 AM ET | #SASBowl

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to connect to databases in SAS Viya

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.

Discussion stats
  • 5 replies
  • 1035 views
  • 4 likes
  • 3 in conversation