BookmarkSubscribeRSS Feed
Sakthivel_Saran
Calcite | Level 5

Hi,

I have a text file with values as mentioned below.  How to import these into SAS with the headers as 1. Date 2. Values?. The dates should be in the date column and the values to be in the other column. I dont want to edit the text file.

 

1Sep11 389.00 1Oct11 491.00 1Nov11 370.00 1Dec11 335.00

and so on.

 

Thanks in advance

4 REPLIES 4
Patrick
Opal | Level 21

@Sakthivel_Saran

Please attach your text file with the first 3 rows. That makes it much easier for us to give you a response.

Alternatively: Use the Import Task in SAS EG or SAS Studio - that might already support you enough to solve this task on your own.

Sakthivel_Saran
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

 

These are the first three lines of the code. I am using SAS 9.0 system for windows. Hope this helps.

Patrick
Opal | Level 21

@Sakthivel_Saran

You can actually ATTACH files instead of posting the data directly into the text. This is sometimes the better option as it provides us with your actual data in the actual format. 

Capture.JPG

How to import these into SAS with the headers as 1. Date 2. 

Where are these headers? Are they the first row in your text file or does your text file directly start with data? Providing the data as an attachment would anser all these questions and also allow us to show you how to use the Import Wizards.

 

You're using SAS 9.0! Why? I hope no serious organization is still using this version. Is this a"hack" version you found on Internet? If so and that's for you onw learning and not for commercial usage then dowload the official, up-to-date and free of charge SAS UE distribution here: https://www.sas.com/en_au/software/university-edition/download-software.html 

 

 

Astounding
PROC Star

Here's an approach that should work:

 

data want;

infile rawdata;

informat date date9.;

input date value @@;

format date yymmdd10.;

run;

 

You will get a message about SAS moving to a new line when it reached past the end of the current line.  For this program, that note is expected and can be ignored.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 851 views
  • 1 like
  • 3 in conversation