BookmarkSubscribeRSS Feed
mkeintz
PROC Star

You have three variables identifying three provider types, and four variables identifying four service types.  So imagine you read in each of your current observations, and making twelve observations from it (corresponding to 3 rows and 4 columns).  The resulting data set, NEED, could have these 3 variables:

 

  1. Provider_type    (with values "Doctor", "Nurse", "Assistant_Physician")  (i.e. the var name of the indicated provider variable)
  2. Service_type ("Consultation .... Procedure")       -  var name of the indicated service variable
  3. MY_FREQ  (the sum of values of the indicated provider and service

So you would 12 times as many observations as you start with.  But you could now do a crosstab of provider_type by service_type, and tell the sas procedure to weight each record by MY_FREQ.

 

Something like

 

   

proc tabulate data=need noseps order=data;
  freq my_freq;
  tables
     provide_type  all='Total' ,
     service_type * N * f=12.0;
run;

 

So now, you need to determine how to create data set NEED.  Consider using two arrays:

  1. An array for rows  (variables doctor, nurse, assistant_physician
  2. An array for cols  (consultation ... procedure)

You can do nested loops, loop through the column array inside a loop over the row array.  Set MY_FREQ to the sum of values for the row variable and the col variable, and then OUTPUT.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 15 replies
  • 1606 views
  • 2 likes
  • 5 in conversation