- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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,
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks so much! This worked!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you! The video was helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.