data have; length a $25 b $4 c $8 d $8 ; input a b c d ; datalines; dept month_ count_ status Acct JAN20 1 0 Eng FEB20 1 1 Sales FEB20 1 1 ; run;
| a | b | c | d | |
| dept | mont | count_ | status | |
| Acct | JAN2 | 1 | 0 | |
| Eng | FEB2 | 1 | 1 | |
| Sales | FEB2 | 1 | 1 | |
| Desire is replace row 1 and make them the header | ||||
| dept | mont | count_ | status | |
| Acct | JAN2 | 1 | 0 | |
| Eng | FEB2 | 1 | 1 | |
| Sales | FEB2 | 1 | 1 | |
I tried
data have2 (firstobs=2);
set have;
;
run;
Good start, although I would put the FIRSTOBS= dataset option on the INPUT dataset and not the OUTPUT dataset.
You also want to use the first row to RENAME the variables.
Here is an easy method using PROC TRANSPOSE.
proc transpose data=have(obs=1) out=names ;
var _all_;
run;
proc sql noprint;
select catx('=',nliteral(_name_),nliteral(col1))
into :renames separated by ' '
from names
where upcase(_name_) ne upcase(col1)
;
quit;
data want;
set have (firstobs=2);
rename &renames;
run;
So your dataset is not named DATA. Use the actual name of your existing dataset.
Also either your first step excluded the SEPARATED BY ' ' clause or your dataset only had one variable.
If you also want to change the variables that look like numbers into numeric variables then you might be able to let PROC IMPORT help you.
filename csv temp;
data _null_;
set have ;
file csv dsd ;
put (_all_) (+0);
run;
proc import datafile=csv dbms=csv out=want replace ;
guessingrows=max;
run;
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.