I'm trying to organize my dataset with multiple variables in a table with descriptive statistics. Some of them are responses to demographic questions, some responses to survey questions, and then there are many additional variables that I do not need to analyze. How do I arrange these in a table so that I see only the variables I want to see and not the ones I don't? (ie drop the ones I don't need or select the ones I do need?) I know I use the:
proc freq
tables
procedure-- just not exactly sure how to go from there. Appreciate any help!
export the variables to Excel and then sort it in the way you like to see in the final output . Delete the variables you don't like to keep. Then run the following code
%let keep_var= <copy and paste the sorted variable names from Excel here or just type in the variable names you like to keep>;
data want;
retain &keep_var.;
set have;
run;
I don't fully understand your question, can you provide more details.
Are you looking to organize a dataset or your output table?
Correct Reeza. I assumed that cnspencer asked about organizing the output data.
Hi Reeza and Mit-- Perhaps my question was misleading-- I'm basically trying to see my data in a table- that summarizes the frequencies and descriptive statistics for only select variables I'm analyzing (some dichotomous, some contininous, and most categorical)- I thought I used:
proc freq;
table (var1) (var2) (var3) (etc..)
Just wondering if there is a better way to do this? So that it will summarize output I want, organized in a way that makes sense for what I'm trying to do (which is describe my population so that I can then look at whether or not those charateristics predict certain outcomes..)
Thanks a lot!
Not really. Generally I'll just run a whole bunch of procs (freq/means) on my variables to first get an idea.
Once I'm more familiar with my data then I follow the standards in this paper for preparing results, primarily for publication. SAS doesn't do this by default, so it takes a bit of manipulation by the coder/user to generate such tables.
A guide for preparing a patient-oriented research manuscript
Thanks Reeza. Yeah I'm pretty skilled/educated on analyzing the output-- it's just getting my data to give me that output (ie knowing the SAS language since I was required to use STATA in school )
Do you just dump all variables in following the table statement? Is it ok to place variables of mixed types (cont/cat/dichot) following the table statement? Also-- do you know a command for merging 2 data sets together so that I can look at everything in one big table?
Thanks!
Check out the UCLA tutorials:
http://www.ats.ucla.edu/stat/sas/
It's fine to dump all the categorical data into a proc freq but useless for continuous variables.
For continuous variables use proc univariate instead.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.