Programming the statistical procedures from SAS

SAS Cleaning Data

Reply
New Contributor
Posts: 2

SAS Cleaning Data

hello i am a graduate student and I have no SAS experience and our biostatistics professor has just thrown us into the programming and we have to clean the data. Her How to clean the data worksheet is hard to understand and everything that i type in comes up with an error statement and just does not work. If there is an easy and understandable way to clean data it would be much appreciated. I need help as soon as possible if there is anyone out there that could reply and help it would be so helpful.

Thanks

Marissa Martinek

Esteemed Advisor
Posts: 7,052

SAS Cleaning Data

You have to provide more info in order for anyone to help.  Are you on a PC or, more specifically, how do you access SAS.  Where is the table located (surely your prof had to tell you something)?  Does your table have a name?

Grand Advisor
Posts: 16,842

Re: SAS Cleaning Data

If she's provided you with a how to clean worksheet she hasn't left you entirely in the dark...

You could post some more info, that spreadsheet for starters, what you've tried also helps.

Here's some quick tutorials on SAS that might be worth learning.

http://www.ats.ucla.edu/stat/sas/notes_old/default.htm

http://www.ats.ucla.edu/stat/sas/sk/modules_sk.htm

SAS does have a learning curve, but that's life!

Good Luck!

New Contributor
Posts: 2

Re: SAS Cleaning Data

ive attached the help sheet and followed a lot of these instructions but literally have gotten no where with error msgs such as : Error 180-322 Statement is not valid or it is used out of proper order. this is what i enter:

if 0 < ridagemn ,= 468 then ridagemn= 'young';

else 469 < ridagemn <= 648 then RIDAGEMN= 'middle';

else 649 < RIDAGEMN <= 1080 then RIDAGEMN= 'old'

run;

RIDAGEMN is my variable name. is that even right?

the only things that ive been able to get right is entering and naming my library, setting data, proc print, and proc freq

I'm currently looking at the sites from reeza

thanks

Esteemed Advisor
Posts: 7,052

Re: SAS Cleaning Data

I doubt that anyone on the forum will do homework for you, but we definitely can provide some direction.

I sounds like you are trying to accomplish a datastep.  Did you start and end it with something like:

data want;

   set have;

  /* this is a comment .. I presume your statement went here.  If not, this is where they should have been */

run;

Now, without even considering if what you tried makes sense, using the above structure it really should have looked like:

data want;

  set have;

  if 0 < ridagemn <= 468 then ridagemn= 'young';

  else if 469 <= ridagemn <= 648 then RIDAGEMN= 'middle';

  else if 649 <= RIDAGEMN <= 1080 then RIDAGEMN= 'old';

run;

HTH,

Art

Grand Advisor
Posts: 16,842

Re: SAS Cleaning Data

Looks like you're trying to recode a variable.

First off, you'll need to store the recoded variable in a new variable so you can't set the ridagemn to young/middle/old.

You're also mixing types (numbers/characters) but ignore that for now.

Second you may have some syntax errors or they're from copying and pasting not sure.

Third you need an else if not just and else statement.

the following should work:

data clean_data;

     set have;

if 0 < ridagemn <= 468 then ridagemn_cat= 'young';

else if 469 < ridagemn <= 648 then RIDAGEMN_cat= 'middle';

else if 649 < RIDAGEMN <= 1080 then RIDAGEMN_cat= 'old'

run;

To check it run a proc freq on your data.

proc freq data=clean_data;

tables ridagemn*ridagemn_cat/missing;

run;

If the variable is continuous you want to check what happens at the boundaries (specifically at 648, 649 and 648.5).

Ask a Question
Discussion stats
  • 5 replies
  • 154 views
  • 1 like
  • 3 in conversation