SAS Studio

Write and run SAS programs in your web browser
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
halladje
Fluorite | Level 6

Hello, 

 

I am looking for a description of the code to recode variables in sas studio. All the codes I have looked up online do not work. 

 

I am looking to recode my age variable so any age 16 thru 22 is coded as missing or '.' 

 

Thanks in advance,

 

1 ACCEPTED SOLUTION

Accepted Solutions
SuzanneDorinski
Lapis Lazuli | Level 10
proc print data=sashelp.class;
run;

data class;
  set sashelp.class;
  if 16 le age le 22 then age=.;
run;

proc print data=class;
run;

View solution in original post

7 REPLIES 7
SuzanneDorinski
Lapis Lazuli | Level 10
proc print data=sashelp.class;
run;

data class;
  set sashelp.class;
  if 16 le age le 22 then age=.;
run;

proc print data=class;
run;
halladje
Fluorite | Level 6

Thanks so much! This worked!

Reeza
Super User
http://video.sas.com/detail/videos/how-to-tutorials/video/4573016759001/performing-conditional-logic...

https://stats.idre.ucla.edu/sas/modules/creating-and-recoding-variables-in-sas/

Also, search LexJansen.com for papers on any topic. It appears to be down right now, but it'll have papers and tutorials on any topic you could want, especially at the beginner level.

The first SAS e-course is also free.
halladje
Fluorite | Level 6

Thank you! The video was helpful. 

ballardw
Super User

@halladje wrote:

Hello, 

 

I am looking for a description of the code to recode variables in sas studio. All the codes I have looked up online do not work. 

 

I am looking to recode my age variable so any age 16 thru 22 is coded as missing or '.' 

 

Thanks in advance,

 


I would be very interested in seeing what did not work and the logs associated with the code that did not work.

halladje
Fluorite | Level 6

I didn't keep any of them because they were not working anyways. I very easily could have been missing a key component - I started using SAS yesterday (I am primarily an SPSS and MlwiN user - converting to SAS). 

 

ballardw
Super User

If you use frequently Value Labels in SPSS you will need to become familiar with Proc Format. Formats are the equivalent of a value label and for some purposes that suffices (binning or grouping).

When data is read either from an external file or an existing variable an INFORMAT is one way to accomplish bulk recoding without a large number of If/then/else statements.

 

I do sypathize with having to make that adjusment. I had to go the other way to SPSS after using SAS for about 13 years.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 2244 views
  • 0 likes
  • 4 in conversation