Hi,
I have tried to read other posts but nothing has worked.
This is an example problem for how to do this with much bigger files.
Essentially, in this example, I have two files, file a and file b. They were originally raw data .txt files, but I am using SAS Studio Linux and find that I have to convert these to .Sas files to work with them. So, I have file a.sas and file b.sas. Both files have the name (File A, or File B) as the first line, and then have the raw data. I am trying to read data from the two files, while skipping over the File A and File B part. So far, nothing has worked.
Here is File_A:
File A
10 20 30
40 50 60
70 80 90
Here is File_B
File B
11 21 31
41 51 61
71 81 91
Here is my attempted code:
---------------------
Libname Learn'/folders/myfolders/Learn' ;
Data Multiple_Files;
If finished=0 then infile'/folders/myfolders/Learn/File_a.sas' end=finished ;
else infile'/folders/myfolders/Learn/file_b.sas' ;
Input @1 ; /*null input to skip over File A and File B
Input X Y Z ;
run ;
----------------------
Here is the ouput I am getting. Note that Not only line1, which has File A and Filbe B, but also Line 3 is missing from both data sets.
Why is this, and how can I correct this, so that only line 1 does not appear? Thanks!
1 | 10 | 20 | 30 |
2 | 70 | 80 | 90 |
3 | 11 | 21 | 31 |
4 | 71 81 91
|
Just use a normal input statement without the @1 but add the firstobs=2 option to your infile statement http://documentation.sas.com/?docsetId=lestmtsref&docsetTarget=n1rill4udj0tfun1fvce3j401plo.htm&docs...
Just use a normal input statement without the @1 but add the firstobs=2 option to your infile statement http://documentation.sas.com/?docsetId=lestmtsref&docsetTarget=n1rill4udj0tfun1fvce3j401plo.htm&docs...
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.