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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.