[英]Statistics problem using SAS- How can I set my input which is given as a range?
您可以使用|
直接使用datalines
輸入它作為分隔符(我們這樣做是因為工資范圍名稱中有空格)。 sgplot
將 plot 直方圖,並且freq=count
選項將告訴sgplot
每個范圍有多少觀察值。
data have;
length salary_range $16.;
infile datalines dlm='|';
input salary_range$ count;
datalines;
25,000 to 29,999|12
30,000 to 34,999|23
35,000 to 39,999|37
40,000 to 44,999|19
45,000 to 49,999|15
50,000 to 54,999|9
;
run;
proc sgplot data=have;
vbar salary_range / freq=count stat=percent;
label salary_range = 'Salary Range';
run;
實際上,您將擁有原始數據並希望使用format
語句來創建您的容器。 例如:
data have;
do i = 1 to 100;
salary = rand('normal', 35000, 2000);
if(salary < 25000) then salary = 25000;
if(salary > 54999) then salary = 54999;
output;
end;
drop i;
run;
proc format;
value salaryRange
25000 - 29999 = '25,000 to 29,999'
30000 - 34999 = '30,000 to 34,999'
35000 - 39999 = '35,000 to 39,999'
40000 - 44999 = '40,000 to 44,999'
45000 - 49999 = '45,000 to 49,999'
50000 - 54999 = '50,000 to 54,999'
;
run;
proc sgplot data=have;
histogram salary;
label salary = 'Salary Range';
format salary salaryRange.;
run;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.