BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Insh_2
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

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;

View solution in original post

9 REPLIES 9
PeterClemmensen
Tourmaline | Level 20

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;

  

Insh_2
Calcite | Level 5
Hi,
Thank you for solution can you please me value@@
PeterClemmensen
Tourmaline | Level 20

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

Insh_2
Calcite | Level 5

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

Tom
Super User Tom
Super User

If you want the data sorted then use PROC SORT.

PeterClemmensen
Tourmaline | Level 20

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;
Tom
Super User Tom
Super User

informat date date9. value 8.2;

 

Why would you want to divide raw values that happened to not include a decimal point by 100?

 

sas-innovate-white.png

Special offer for SAS Communities members

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.

 

View the full agenda.

Register now!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 1714 views
  • 0 likes
  • 3 in conversation