Help using Base SAS procedures

How do I organize my data?

Reply
New Contributor
Posts: 4

How do I organize my data?

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!

Frequent Contributor
Frequent Contributor
Posts: 83

Re: How do I organize my data?

Posted in reply to cnspencer

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;

Super User
Posts: 19,855

Re: How do I organize my data?

Posted in reply to cnspencer

I don't fully understand your question, can you provide more details.

Are you looking to organize a dataset or your output table?

Frequent Contributor
Frequent Contributor
Posts: 83

Re: How do I organize my data?

Correct Reeza. I assumed that cnspencer asked about organizing the output data.

New Contributor
Posts: 4

Re: How do I organize my 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!

Super User
Posts: 19,855

Re: How do I organize my data?

Posted in reply to cnspencer

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

New Contributor
Posts: 4

Re: How do I organize my data?

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 Smiley Sad)

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!

Super User
Posts: 19,855

Re: How do I organize my data?

Posted in reply to cnspencer

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.

Ask a Question
Discussion stats
  • 7 replies
  • 435 views
  • 0 likes
  • 3 in conversation