BookmarkSubscribeRSS Feed
mmartinek24
Calcite | Level 5

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

5 REPLIES 5
art297
Opal | Level 21

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?

Reeza
Super User

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!

mmartinek24
Calcite | Level 5

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

art297
Opal | Level 21

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

Reeza
Super User

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).

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1474 views
  • 1 like
  • 3 in conversation