9aug11 112 9sept11 225
10aug11 226 10sep11 568
i have data like this in raw text file how to read it like
9aug11 112
10aug11 226
9sep11 225
10sep11 568
Then do like this
data want;
infile "c:\Users\Peter\Desktop\mytxt.txt";
input date value @@;
informat date date9. value;
format date date9. value 8.2;
run;
proc sort data=want;
by date;
run;
Welcome to the SAS communities 🙂
The code looks something like this. However, is your second date value really 9sept11? This will make the date9. informat result in a missing value.
data want;
infile "c:\Users\Peter\Desktop\mytxt.txt";
input date:date9. value @@;
format date date9.;
run;
I assume that you are asking for an explanation.
value is simply the name for the second variable in your data. I made that up. Could be any valid SAS variable name.
@@ holds the input record for the execution of the next INPUT statement across iterations of the DATA step. You can read more about it in the SAS Input Statement Documentation.
1Sep11 389.00 1Oct11 491.00 1Nov11 370.00 1Dec11 335.00
2Sep11 423.00 2Oct11 478.00 2Nov11 407.00 2Dec11 442.00
3Sep11 482.00 3Oct11 300.00 3Nov11 303.00 3Dec11 372.00
4Sep11 407.00 4Oct11 405.00 4Nov11 398.00 4Dec11 465.00
5Sep11 354.00 5Oct11 388.00 5Nov11 427.00 5Dec11 393.00
6Sep11 432.00 6Oct11 387.00 6Nov11 360.00 6Dec11 393.00
7Sep11 476.00 7Oct11 330.00 7Nov11 494.00 7Dec11 498.00
8Sep11 426.00 8Oct11 412.00 8Nov11 444.00 8Dec11 314.00
9Sep11 439.00 9Oct11 322.00 9Nov11 392.00 9Dec11 404.00
my data is like that where there are different dates for different months
@@ is printing data like
1sep11
1oct11
1nov11
1dec11
2sep and so on..
but i want it like
1sep11
2sep11
.
.
1oct11
2oct11
.
.
1nov11
2nov11
like this
If you want the data sorted then use PROC SORT.
Then do like this
data want;
infile "c:\Users\Peter\Desktop\mytxt.txt";
input date value @@;
informat date date9. value;
format date date9. value 8.2;
run;
proc sort data=want;
by date;
run;
informat date date9. value 8.2;
Why would you want to divide raw values that happened to not include a decimal point by 100?
@Tom, right as usual 🙂 I corrected it.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.