我的sasdata输出是这样的。
我们可以按特定顺序制作值吗?(更改行的顺序)
即“小于10万,10-20万,21-30 ......超过1千万”的顺序。
我想更改行顺序。现在行按升序排序。我们可以手动订购吗?
答案 0 :(得分:2)
构建格式并在格式值后对数据进行排序:
PROC FORMAT;
INVALUE I_range
'Above Rs. 1 Crore' = 6
'Between Rs. 10-20 lakh' = 2
'Between Rs. 21-30 lakh' = 3
'Between Rs. 31-50 Lakh' = 4
'Between Rs. 51 Lakh - Rs. 1 Crore' = 5
'Less than Rs. 10 Lakh' = 1
;
RUN;
DATA Temp_order;
SET HSI_Income_Range;
order_data = INPUT(IncomeRange,I_range.);
RUN;
PROC SORT DATA = Temp_order;
BY order_data;
RUN;
data HSI_Income_Range (Drop= order_data);
set Temp_order;
run;
答案 1 :(得分:0)
DATA Out.Temp_order;
SET Out.HSI_income_range;
if income_range="Above Rs. 1 Crore" then dummy_column= 6;
if income_range="Between Rs. 10-20 lakh" then dummy_column= 2;
if income_range="Between Rs. 21-30 lakh" then dummy_column= 3 ;
if income_range="Between Rs. 31-50 Lakh" then dummy_column= 4 ;
if income_range="Between Rs. 51 Lakh – Rs. 1 Crore" then dummy_column= 5;
if income_range="Less than Rs. 10 Lakh" then dummy_column= 1;
RUN;
PROC SORT DATA = Out.Temp_order;
BY dummy_column;
RUN;
data Out.HSI_income_range (Drop=dummy_column);
set out.Temp_order;
run;