Hello! I am very VERY new to SAS and I am stuck in something very basic. I am working with SAS Studio and am trying to get the number of records (n), mean, standard deviation, minimum, and maximum values for each column for a data set. I enter:
PROC MEANS DATA=myData n min max mean std;
var _numeric_;
RUN;
or
PROC MEANS DATA=myData n min max mean std;
var col1 col2 col3;
RUN;
Thank you @novinosrin . That makes total sense! But now I got stuck a bit further...
Please help!!!!!!!
Plz check if you have
1. A dataset by the name mydata
2. if yes, run
proc contents data=mydata;
run;
the results should tell you the info about variables in the dataset
3 if the above 2 is fine, run proc means as suggested
I got this.. seems like the type is Char
Alphabetic List of Variables and Attributes# Variable Type Len Format Informat Label21
B | Char | 109 | $109. | $109. | B |
FRED_Graph_Observations | Char | 42 | $42. | $42. | FRED Graph Observations |
But my dataset contains numbers, which is where I need to get the summary statistics from
1 | Federal Reserve Economic Data |
2 | Link: https://fred.stlouisfed.org |
4 | Economic Research Division |
5 | Federal Reserve Bank of St. Louis |
6 |
7 | A191RL1Q225SBEA | Real Gross Domestic Product, Percent Change from Preceding Period, Quarterly, Seasonally Adjusted Annual Rate |
8 |
9 | Frequency: Quarterly |
10 | observation_date | A191RL1Q225SBEA |
11 | 17258 | -1 |
12 | 17349 | -.8 |
13 | 17441 | 6.4 |
14 | 17533 | 6.2 |
15 | 17624 | 6.8 |
16 | 17715 | 2.3 |
17 | 17807 | .4 |
18 | 17899 | -5.4 |
19 | 17989 | -1.4 |
20 | 18080 | 4.2 |
21 | 18172 | -3.3 |
22 | 18264 | 16.7 |
23 | 18354 | 12.8 |
24 | 18445 | 16.4 |
25 | 18537 | 7.9 |
26 | 18629 | 5.5 |
27 | 18719 | 7.1 |
28 | 18810 | 8.5 |
29 | 18902 | .9 |
30 | 18994 | 4.3 |
31 | 19085 | .9 |
32 | 19176 | 2.9 |
33 | 19268 | 13.8 |
34 | 19360 | 7.6 |
35 | 19450 | 3.1 |
36 | 19541 | -2.2 |
37 | 19633 | -5.9 |
38 | 19725 | -1.9 |
39 | 19815 | .4 |
40 | 19906 | 4.6 |
41 | 19998 | 8.1 |
42 | 20090 | 11.9 |
43 | 20180 | 6.7 |
44 | 20271 | 5.5 |
45 | 20363 | 2.4 |
46 | 20455 | -1.5 |
47 | 20546 | 3.3 |
48 | 20637 | -.4 |
49 | 20729 | 6.7 |
50 | 20821 | 2.6 |
51 | 20911 | -.9 |
52 | 21002 | 4 |
53 | 21094 | -4.1 |
54 | 21186 | -10 |
55 | 21276 | 2.7 |
56 | 21367 | 9.6 |
57 | 21459 | 9.7 |
58 | 21551 | 7.9 |
59 | 21641 | 9.3 |
60 | 21732 | .3 |
61 | 21824 | 1.1 |
62 | 21916 | 9.3 |
63 | 22007 | -2.1 |
64 | 22098 | 2 |
65 | 22190 | -5 |
66 | 22282 | 2.7 |
67 | 22372 | 7 |
68 | 22463 | 7.9 |
69 | 22555 | 8.1 |
70 | 22647 | 7.3 |
71 | 22737 | 3.7 |
72 | 22828 | 5 |
73 | 22920 | 1.3 |
74 | 23012 | 4.4 |
75 | 23102 | 4.6 |
76 | 23193 | 9.1 |
77 | 23285 | 2.6 |
78 | 23377 | 8.7 |
79 | 23468 | 4.4 |
80 | 23559 | 6.4 |
81 | 23651 | 1.2 |
82 | 23743 | 10 |
83 | 23833 | 5.1 |
84 | 23924 | 9.2 |
85 | 24016 | 9.5 |
86 | 24108 | 10.1 |
87 | 24198 | 1.4 |
88 | 24289 | 3.4 |
89 | 24381 | 3.3 |
90 | 24473 | 3.6 |
91 | 24563 | .2 |
92 | 24654 | 3.8 |
93 | 24746 | 3 |
94 | 24838 | 8.4 |
95 | 24929 | 6.9 |
96 | 25020 | 3.1 |
97 | 25112 | 1.6 |
98 | 25204 | 6.4 |
99 | 25294 | 1.2 |
100 | 25385 | 2.7 |
if the values are all numbers but are stored as char, keep it simple as you learn
/*convert char to num*/
data num_result;
set input_dataset;
num_var1=input(char_var1,8.);
num_var2=input(char_var2,8.);/*and so on*/
run;
Then use the num_result dataset as input in your proc means as discussed previously
Thank you!!
That explains why PROC MEANS was only showing you the number of observations. You need to have numeric variables to be able to calculate statistics like MEAN.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.