Hi,
I have a dataset as below.
data have;input name $ Var1 Var2 Var3 Var4;datalines;AA 0 0 0 1 AA 0 1 0 0BB 0 0 1 0 BB 1 0 0 0run;
I want the dataset as below.
ID Var_Con
AA 0101
BB 1010
what program do I need to use? Thanks.
data have; input name $ Var1 Var2 Var3 Var4; datalines; AA 0 0 0 1 AA 0 1 0 0 BB 0 0 1 0 BB 1 0 0 0 ; run; proc summary data=have nway; class name; var var1-var4; output out=temp(drop=_:) sum=; run; data want; set temp; length var_con $4; var_con=cats(of var1-var4); keep name var_con; run;
View solution in original post
Maybe like this:
data have; input name $ Var1 Var2 Var3 Var4; datalines; AA 0 0 0 1 AA 0 1 0 0 BB 0 0 1 0 BB 1 0 0 0 ; run; data want; set have; by name; array A Var:; array B[4] _temporary_; do over A; B{_i_} + A; end; if last.name then do; var_con = cats(of B[*]); output; call missing(of B[*]); end; keep name var_con; run;
All the best
Bart
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!
Register now
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.