- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
In the code below, I am looking to make the 'adult_pop' variable name capital (ADULT_POP) and make the observations that are within the COUNTY variable proper case. I have tried everything I can think of, so I'm looking for a fresh and more experienced set of eyes. Thanks for any insight!
DATA WORK.Illus; MERGE CoImpt.PhysicalActivity CoImpt.Geo_Reference_Table; KEEP FIPS COUNTY TRACT_NAME adult_pop; RUN;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
SAS is case insensitive with regards to names of datasets, variables and other objects, so the casing is irrelevant.
Dataset names are kept internally as all uppercase, while the physical filenames are all lowercase.
Only variable names are kept in the casing they were entered.
If you want something special, put it in a label.
You might try if a RENAME works:
data work.illus;
merge
coImpt.physicalactivity
coImpt.geo_reference_table
;
keep FIPS COUNTY TRACT_NAME adult_pop;
rename adult_pop=ADULT_POP;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
First, change the order of the statements. Move the KEEP statement to before the MERGE statement.
Second, change the spelling to all caps in the KEEP statement.
As Kurt mentioned, the first mention of the variable determines the default (unlabeled) spelling used in reporting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@BLT2023 wrote:
In the code below, I am looking to make the 'adult_pop' variable name capital (ADULT_POP) and make the observations that are within the COUNTY variable proper case. I have tried everything I can think of, so I'm looking for a fresh and more experienced set of eyes.
Why? Is it because you want upper case headings in a report or table that you will make use of? As always context is everything, we can offer better solutions if we knew WHY you are doing something.
So yes, you can force SAS to make the variable name upper case, as explained by @Kurt_Bremser and @Astounding, but it simply isn't necessary, its extra work with little benefit, IMHO. Just because you can do something doesn't mean you should do that thing. Better, you might want to assign a label to the variable, in which case you can then make the label whatever case you want, and make it more readable, so instead of ADULT_POP, do your audience a favor and use actual English (not computerese) labels, such as the label "Adult Population" (or similar). In reporting procedures such as PROC PRINT, PROC TABULATE and PROC REPORT, the labels (in real English, not computerese) will be used and your audience will be grateful.
Paige Miller