Hi there
I am trying to create the following type of table in SAS manually and then practice getting means, standard deviations, and interquartile ranges from the data and table. I am not sure what type of code to use to efficiently input the data into SAS without having to repeatedly key in each value.
Thank you for your help.
Hi @AbhilashS and welcome to the SAS Support Communities!
You can create the dataset as PaigeMiller suggested or, e.g., like this:
data have;
hours=4+_n_;
input n @@;
cards;
3 8 20 11 6 2
;
Then apply PROC UNIVARIATE to dataset HAVE using the FREQ statement
freq n;
(or freq frequency; if you used this variable name in the INPUT statement) to compute the statistics.
Alternatively, create the dataset with only one variable (hours), but with 50 observations rather than 6, and then omit the FREQ statement in the analysis:
data have;
hours=4+_n_;
input _n_ @@;
do _n_=1 to _n_;
output;
end;
cards;
3 8 20 11 6 2
;
Here's how you input the first two rows
data have;
input hours frequency;
cards;
5 3
6 8
;
It's not clear what you mean by "without having to repeatedly key in each value"? Is the data in a file (text file, csv file, excel file) somewhere? What does the word "repeatedly" refer to? Why do you think this would have to be done "repeatedly"?
Hi @AbhilashS and welcome to the SAS Support Communities!
You can create the dataset as PaigeMiller suggested or, e.g., like this:
data have;
hours=4+_n_;
input n @@;
cards;
3 8 20 11 6 2
;
Then apply PROC UNIVARIATE to dataset HAVE using the FREQ statement
freq n;
(or freq frequency; if you used this variable name in the INPUT statement) to compute the statistics.
Alternatively, create the dataset with only one variable (hours), but with 50 observations rather than 6, and then omit the FREQ statement in the analysis:
data have;
hours=4+_n_;
input _n_ @@;
do _n_=1 to _n_;
output;
end;
cards;
3 8 20 11 6 2
;
Thank you both PaigeMiller and FreelanceReinhard. I tried the last code and found it a best fit. I am only starting so I apologize for some nonsensical questions. The answers matched what I was looking for from 50 responses.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.