how to read observations from a dataset 3 times,how many ways(without point)
have dataset:
ranks
1
2
want dataset:
ranks
1
2
1
2
1
2
set have have have;
set have have have;
And check some functions about it like fetchobs( ) .
Can I check why? It seems in your example you want a dataset with a 1, 2 combination 3 times. There are better ways than creating one dataset and then appending that three times, do loops for instance, retain statement setting the value != previous etc.
sorry.
could u pls provide me the logic
One more way
proc sql;
select * from have
union all
select * from have
union all
select * from have;
quit;
If you don't want to waste space, create a view:
data want / view=want;
set have have have;
run;
PG
How silly are we allowed to get? Why write something simple when you can confuse everybody with a macro?
%macro silly;
%local N i j;
data _null_;
set have nobs=_total_obs_;
call symputx ('N', _total_obs_);
run;
data want;
%do i=1 %to 3;
%do j=1 %to &N;
set have (firstobs=&j obs=&j);
output;
%end;
%end;
run;
%mend silly;
%silly
First rule of obfuscation club is...
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.