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

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!

 

                 X           Y           Z
1102030
2708090
3112131
4

 71        81           91                           

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisBrooks
Ammonite | Level 13

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...

View solution in original post

1 REPLY 1
ChrisBrooks
Ammonite | Level 13

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...

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 12418 views
  • 0 likes
  • 2 in conversation