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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1 reply
  • 10336 views
  • 0 likes
  • 2 in conversation