hi,
i have some question......i have 100 observations.............. i want to assign every 10 observations to new column
shall i try with firstobs , obs or
mod (_n_,10).......??
i have data like this .
NAV:
34
33
32
31
..
.
.
.
.
.
.
.
.78 (100 the observation)
want the cloulmns as below
1_10 2_10 3 _10 4_10 5_10..........................
Regards
Allu
What are you wanting the value to be in the new column? The sum of something, count of something? or is it that you would ultimately want your data like this:
1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30
yes ...i need the Observation values in cloumn wise ...............
1_10 2_10 3_10............
1 11
2 12
3 13
... .
. .
. .
10 20
Regards
Allu
how about;;
data want;
set have;
if _N_<10 then ColName='1_10';
else if _N_ < 20 then ColName='2_10';
.
.
.
else ColName='10_10';
run;
then proc transpose on colname
If this is what you want, if your RAM is large enough to hold your table in whole.
data have;
do nav=1 to 99;
output;
end;
run;
data _null_;
call symputx('obs', ceil(nobs/10));
stop;
set have nobs=nobs;
run;
data want;
do i=1 to &obs ;
do j=1 to 10;
set have end=last;
array t(10,&obs.) _temporary_;
array _(&obs.);
t(j,i)=nav;
if last then leave;
end;
end;
do j=1 to 10;
do i=1 to &obs;
_(i)=t(j,i);
end; output;
end;
stop;
keep _:;
run;
Haikuo
Self-merge skill is suited for your question, If your dataset is large ,using a macro variable to wrap it.
data want;
merge have(firstobs=1 obs=10 rename=(nav=nav1))
have(firstobs=11 obs=20 rename=(nav=nav2))
..........
;
run;
Ksharp
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.