Use double-dash to indicate a range of variables (in the order they are defined in the program data vector, I assume).
Source code:
data _null_;
input a b c $ d e $ f;
put b--e;
datalines;
1 2 w 4 x 6
2 4 y 8 z 12
;
run;
Log:
2 w 4 x
4 y 8 z
Friday, November 15, 2013
Friday, November 1, 2013
SAS: Concatenate strings and numbers using CATX function
No more trim'ing and left'ing! SAS' CATX function lets you concatenate strings and numbers!
Source code:
data _null_;
attrib result length=$20;
input name $ date_as_number : anydtdte12. ;
date_as_string = put(date_as_number, mmddyy10.);
result = catx("*", name, date_as_number);
put result=;
result = catx("*", name, date_as_string);
put result=;
datalines;
Cora 19840723
Hannah 19880626
Emma 19900411
;
run;
Log:
1 data _null_;
2 attrib result length=$20;
3 input name $ date_as_number : anydtdte12. ;
4 date_as_string = put(date_as_number, mmddyy10.);
5 result = catx("*", name, date_as_number);
6 put result=;
7 result = catx("*", name, date_as_string);
8 put result=;
9 datalines;
result=Cora*8970
result=Cora*07/23/1984
result=Hannah*10404
result=Hannah*06/26/1988
result=Emma*11058
result=Emma*04/11/1990
NOTE: DATA statement used (Total process time):
real time 0.09 seconds
cpu time 0.04 seconds
13 ;
14 run;
Source code:
data _null_;
attrib result length=$20;
input name $ date_as_number : anydtdte12. ;
date_as_string = put(date_as_number, mmddyy10.);
result = catx("*", name, date_as_number);
put result=;
result = catx("*", name, date_as_string);
put result=;
datalines;
Cora 19840723
Hannah 19880626
Emma 19900411
;
run;
Log:
1 data _null_;
2 attrib result length=$20;
3 input name $ date_as_number : anydtdte12. ;
4 date_as_string = put(date_as_number, mmddyy10.);
5 result = catx("*", name, date_as_number);
6 put result=;
7 result = catx("*", name, date_as_string);
8 put result=;
9 datalines;
result=Cora*8970
result=Cora*07/23/1984
result=Hannah*10404
result=Hannah*06/26/1988
result=Emma*11058
result=Emma*04/11/1990
NOTE: DATA statement used (Total process time):
real time 0.09 seconds
cpu time 0.04 seconds
13 ;
14 run;
Subscribe to:
Posts (Atom)