Reputation: 3
I'm pretty new to SAS coding and I'm just trying to create a data set with a data step but I don't really know how. Its a small set with 4 variables and 3 observations I tried varying things with the code below but I don't know how to do more than one observation at a time.
data new_exec;
ID = 'A';
Adj_ROA = 1.56;
Adj_Returns=3.74;
Total_Assets= 7850;
run;
I have 3 ids A B and C then 3 numeric values for each other variable. I just don't know how to make the data set.
Upvotes: 0
Views: 614
Reputation: 21274
Creating a data set from 'nothing' isn't as common as you'd think, but a data step is relatively easy to create.
Note if you're trying to run this, make sure to align it to the edge of the window first.
Data Have;
infile cards dlm=',';
length ID $1. AdjROA ADJ_REturns total_Assets 12.;
input ID AdjROA ADJ_REturns total_Assets;
cards;
A, 1.56, 3.74, 7850
B, 2.1, 4.5, 2834
;;;;
run;
Upvotes: 1
Reputation: 51566
To write multiple observations you can add explicit OUTPUT
statements.
data new_exec;
ID = 'A';
Adj_ROA = 1.56;
Adj_Returns=3.74;
Total_Assets= 7850;
output;
ID = 'B';
.....
output;
ID = 'C';
.....
output;
run;
Or just place the data in-line with the program and read it with an INPUT statement. Note use a period for missing values (both numeric and character).
data new_exec;
input id $ Adj_ROA Adj_Returns Total_Assets ;
datalines;
A 1.56 3.74 7850
B 2.1 3.5 5677
C . 4 78909
;
Upvotes: 1