BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
agille05
Fluorite | Level 6

Hi all, 

 

First name here and in need of some assistance. I have a dataset that looks something like the following:

 

Q4 Q5_1 Q5_2 Q5_3

 1        1       1       2

 2        1       1       1

 1        1       0       2

 5        2       1       2

 

The values within the Q5_1, Q5_2, and Q5_3 columns are of the same type and I am looking to determine the frequency of the responses across the entire matrix (Q4 is a participant type). I have been able to develop an IML code to produce an output table for just one of the participant types as below. 

 

PROC IML;
   Use Data.Have;
   Read all var{Q5_1 Q5_2 Q5_3} where (Q4 = 1) into x;
Close;
Call tabulate(level,freq,x,);
Print (level`)[l='level'] (freq`)[l='freq'];
Quit;

 

This generates an output table that looks like the following:

 

level freq
0151
11399
2206

 

What I am wondering is if it is possible to save this output table as a new dataset after using the Call Tabulate function?

 

Appreciate any and all suggestions and thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Yes. you could. but you have to post it at IML forum.

https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bd-p/sas_iml

 

data have;
input Q4 Q5_1 Q5_2 Q5_3;
cards;
 1        1       1       2
 2        1       1       1
 1        1       0       2
 5        2       1       2
;

PROC IML;
   Use Have;
   Read all var{Q5_1 Q5_2 Q5_3} where (Q4 = 1) into x;
Close;
Call tabulate(level,freq,x,);

create want var{level freq};
append ;
close;
Quit;

View solution in original post

5 REPLIES 5
Ksharp
Super User

Yes. you could. but you have to post it at IML forum.

https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bd-p/sas_iml

 

data have;
input Q4 Q5_1 Q5_2 Q5_3;
cards;
 1        1       1       2
 2        1       1       1
 1        1       0       2
 5        2       1       2
;

PROC IML;
   Use Have;
   Read all var{Q5_1 Q5_2 Q5_3} where (Q4 = 1) into x;
Close;
Call tabulate(level,freq,x,);

create want var{level freq};
append ;
close;
Quit;
agille05
Fluorite | Level 6

Hi all, 

 

First name here and in need of some assistance. I have a dataset that looks something like the following:

 

Q4 Q5_1 Q5_2 Q5_3

 1        1       1       2

 2        1       1       1

 1        1       0       2

 5        2       1       2

 

The values within the Q5_1, Q5_2, and Q5_3 columns are of the same type and I am looking to determine the frequency of the responses across the entire matrix (Q4 is a participant type). I have been able to develop an IML code to produce an output table for just one of the participant types as below. 

 

PROC IML;
   Use Data.Have;
   Read all var{Q5_1 Q5_2 Q5_3} where (Q4 = 1) into x;
Close;
Call tabulate(level,freq,x,);

Print (level`)[l='level'] (freq`)[l='freq'];

Quit;

This generates an output table that looks like the following:

 

level freq
0151
11399
2206

 

What I am wondering is if it is possible to save this output table as a new dataset after using the Call Tabulate function?

Appreciate any and all suggestions! Thank you 🙂

 

Rick_SAS
SAS Super FREQ

KSharp has already answered your question. See the end of his program.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 5 replies
  • 968 views
  • 3 likes
  • 3 in conversation