Hi to all,
How to perfume that esealy without using iml ?
Regards
data have;
q 0.2
w 0.3
e 0.4
r 0.5
t 0.6
y 0.11
data want:
q w e r t y
0.2 0.3 0.4 0.5 0.6 0.11
0.2 0.3 0.4 0.5 0.6 0.11
0.2 0.3 0.4 0.5 0.6 0.11
0.2 0.3 0.4 0.5 0.6 0.11
0.2 0.3 0.4 0.5 0.6 0.11
... n time the sames lines, n known.
Use call execute off dataset have:
data have;
input name $ value;
cards;
q 0.2
w 0.3
e 0.4
r 0.5
t 0.6
y 0.11
;
run;
%let n=5;
data _null_;
set have end=done;
if _n_ = 1 then call execute('data want;');
call execute(strip(name) !! ' = ' !! put(value,best.) !! ';');
if done then call execute("do i = 1 to &n; output; end; drop i; run;");
run;
Transpose and then set X number of times, though not sure why you would A) want this structure, and B) want to repeat the same data lots of times?
proc transpose data=have out=want; by col1; var col2; run; data want; set want want want want want; run;
Also, when posting test data in the form of a datastep, it should really be runnable, what you post doesn't really help as doesn't show structure.
Many thanks !
When using proc template, get an error msg.
--------------------------------------------
612 proc transpose data=have out=want;
613 by col1;
ERROR: Variable COL1 introuvable.
614 var col2;
615 run;
--------------------------------------------
Also as n is very high, will have to "set want" hundreds of times
Regards
Sorry, can't find any google search results on:
ERROR: Variable ___ introuvable.
??
From your post however, again the question arises, why do you want hundreds of the same data? This doesn't make any sense to me? I mean you can do it, just have something like:
data want; set sashelp.class (keep=name age); do rowid=1 to 10; output; end; run; proc sort data=want; by rowid name; run; proc transpose data=want out=want; by rowid; var age; id name; run;
But all that is doing is taking some data and multiplying its storage factor up by 10 for no gain?
Use call execute off dataset have:
data have;
input name $ value;
cards;
q 0.2
w 0.3
e 0.4
r 0.5
t 0.6
y 0.11
;
run;
%let n=5;
data _null_;
set have end=done;
if _n_ = 1 then call execute('data want;');
call execute(strip(name) !! ' = ' !! put(value,best.) !! ';');
if done then call execute("do i = 1 to &n; output; end; drop i; run;");
run;
Thanks, works very well with call execute !
Could suggest a smart update if n is the number of rows in data have ?
That is 6 in this case. Always without using iml.
Regards
@DoumbiaS wrote:
Thanks, works very well with call execute !
Could suggest a smart update if n is the number of rows in data have ?
That is 6 in this case. Always without using iml.
Regards
Use _n_ to automatically get the number:
data _null_;
set have end=done;
if _n_ = 1 then call execute('data want;');
call execute(strip(name) !! ' = ' !! put(value,best.) !! ';');
if done then call execute("do i = 1 to " !! put(_n_,best.) !! "; output; end; drop i; run;");
run;
Thanks,
B Regards
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.