01-30-2017 05:49 PM
I'm copy/pasting a large dataset into Excel so I can use Tableau to make pretty graphics (boss's desire so no option here). For categorical ("string" or "abc" in Tableau parlance) variables, Tableau likes to work with the "labels" not the numeric values (unless you do some contorted "aliasing" stuff). I have some variables in the SAS data that are numeric but I've assigned labels via Proc format. But they don't show as labels in the data - they still show as just the original numerics. Again, I want the actual data to show the labels, not numbers, so I can cut/paste it that way. Is there an easy way to get the SAS data to show (I work in the Enterpise thingee) the labels instead of the original numeric values? That way I can just cut/paste into Excel. I suppose I could do a data step and force the same proc format statements through the "attrib" statement in the data step and create a new variable, but was hoping for an easier way since that entails cleaning up that "attrib if/then forest" code for 100's of lines. (p.s. To show values or value labels is a simple click of the mouse in SPSS. Why does SAS have to overcomplicate everything?!)
Another thing I can't get SAS to do is output (in basic stuff like summary stats (proc means proc freq etc) both the variable values and their labels! Again, in SPSS that is a simple click in general defaults. I cannot find out how to do that simple thing in SAS - it wants to either spit out the values or if you throw in a format statement then it spits out the labels....BUT it won't do both values and labels (that I can tell). Any ideas?
Ugh... I used to be an expert in SAS (I thought) - my dang dissertation was an IML program that ran for hours on end!! Now 20 years later after using SPSS, I'm being forced to use SAS again .... and guess what? I'm not liking SAS too much.... The simplest of things get so overcomplicated....frustrating. Oh well. Thanks,
01-30-2017 05:58 PM - edited 01-30-2017 05:59 PM
I don't work with EG, so this might not work, but would submitting the simple line:
Art, CEO, AnalystFinder.com
p.s. I like SAS more than SPSS. Just takes a bit to get used to the differences.
01-30-2017 06:05 PM
01-30-2017 06:22 PM
I'd try it again, but moving the options label statement to precede the proc statement. i.e.,
options label; proc freq; title "xtabs by RESIDENT by foremp1"; tables formemp1*resident / missing nocum nopercent norow nocol; format formemp1 emptypefmt.; run;
Art, CEO, AnalystFinder.com
p.s. for me that solved the extra credit question as well
01-31-2017 10:55 AM
01-30-2017 06:24 PM
SAS won't do formatted values and underlying values at the same time. Although you're talking about 'labels' that has a different meaning in SAS - it refers to the variable label, not a value label which is what I think you're referring to.
Unfortunately the way to do this is likely to create a new variable that essentially converts the format. I'm not a huge fan of this because then you lose the dynamic nature unless you structure your program appropriately.
So using SAS EG and Query Builder, use a computed column to convert the value to a new variable.
Then use this new variable as well in your PROC FREQ.
If you're programming it would look like:
data want; set have; foremp1_formatted = put(formemp1, emptypefmt.); run; proc freq data=want; tables formemp1*formemp1_formatted*resident/.....; run;
PS Everything is easier in the 'language' you know, but having worked with both for a while SAS is significantly more powerful than SPSS though it does require some investment in knowledge. Sometimes it is more steps to accomplish simple things, but the power of the automation features is almost unparalleled to any of the other languages I've worked with, including R/Python.