Programming the statistical procedures from SAS

One subject with Multiple Observations

Reply
Occasional Contributor
Posts: 11

One subject with Multiple Observations

Hello - I am extremely green with SAS, so I apologize in advance if this question is overly simple. I've gone through 5 books and can't seem to find what I need.

I have a dataset of medical providers that have submitted data. There are over 9000 lines of data that only a few providers submitted...and I just need simple summary data. See an example below:

Provider ID     Facility Type     Storage Unit Type     Out of Temperature Range? (0=No 1=Yes)     Start Date/Time

011234          Health Dept          Freezer                       0                                                                   1/18/2014  10:36

011234          Health Dept          Freezer                       1                                                                   2/14/2014  15:21

011234          Health Dept          Fridge                         1                                                                   2/28/2014   1:51

059222          Private                  Fridge                         1                                                                   1/5/2014    3:15

059222          Private                  Fridge                         0                                                                   1/12/2014   22:30

352988          Health Dept          Freezer                       1                                                                    3/2/2014   8:34

352988          Health Dept          Freezer                       0                                                                    3/4/2014   9:54

470154          Private                  Freezer                       0                                                                    4/1/2014  11:28

470154          Private                  Fridge                         1                                                                    5/20/2014  10:18

I can't figure out the programming that will give me summary data that tells me there were 4 providers - 2 health departments and 2 private medical facilities...and that this data came from 3 freezers and 3 refrigerators. Thanks so much!

Esteemed Advisor
Esteemed Advisor
Posts: 6,977

Re: One subject with Multiple Observations

Hi,

Well there is proc summary: Base SAS(R) 9.2 Procedures Guide

Personally I don't use it so can't give an example.  I tend to use other methods - proc means, SQL.  So depends how you want your output to look, one way is:

data have;

  infile datalines dlm=",";

  input provider $ facility $ storage $;

datalines;

0011234,Health Dept,Freezer

0011234,Health Dept,Fridge

059222,Private,Fridge

;

run;

proc sql;

  create table WANT as

  select  "Provider",

          count(distinct PROVIDER) AS CNT

  from    HAVE

  union all

  select  "Facility",

          count(distinct FACILITY) AS CNT

  from    HAVE

  union all

  select  "Storage",

          count(distinct STORAGE) AS CNT

  from    HAVE;

quit;

Occasional Contributor
Posts: 11

Re: One subject with Multiple Observations

Thank you, RW9! I will try this. I really appreciate your response. Smiley Happy

Esteemed Advisor
Esteemed Advisor
Posts: 6,977

Re: One subject with Multiple Observations

No probs.  As I say though, check out the procedures that are available as well, most will be easier to work with if they do what you want.  I tend to be using the counts and such like in other things and as part of a bigger SQL statement, so running a proc then going back to the SQL is a pain.

SAS Employee
Posts: 187

Re: One subject with Multiple Observations

Just a simple application of PROC FREQ:

proc freq;

tables provider facility storage;

run;

or, if you just need the number of levels in each variable and not the counts of observations in each level:

proc freq nlevels;

tables provider facility storage / noprint;

run;

Ask a Question
Discussion stats
  • 4 replies
  • 290 views
  • 0 likes
  • 3 in conversation