Please advise...I need to transponse time period (format YYYYMM) by an ascending sequence. But I always become transposed result such a: 201201, 201203, 201103, 201204,... What should I do to get the ascending time period?
example of column:
Period
201203
201204
201106
201201
201103
Proc Transpose creates new variables in the order that it finds the id values in your dataset. One way to get what you want is to make sure that your first by-group contains all the id values in ascending sequence (by adding missing value observations if necessary). Another way is to reorder the columns after transposition with a datastep where the variables are named in ascending order in a RETAIN statement.
PG
Is this what you want?
data have;
informat period yymmn6.;
format period yymmn6.;
input period;
cards;
201203
201204
201106
201201
201103
;
proc transpose data=have out=want(drop=_:) prefix=period;
var period;
run;
data want;
set want;
call sortn (of p:);
run;
proc print;run;
Obs period1 period2 period3 period4 period5
1 201103 201106 201201 201203 201204
Linlin
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.
Find more tutorials on the SAS Users YouTube channel.