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

Hi to all!!!

I have to read one file with only one SINGLE record and put it in SAS table with more records. the file is with this one record:

19941231 C   19950216 19950216 16000000 18300000                                19951231 C T 19960226 19960226 17060000 20150000                                19961130     19961207 19961207 10000000 18000000 ......               ..................                              .....................................               ......................

obviously the record is more  long.

In general I make infile with multiple record and I hadn't any problems but I have some problems to create a sas program which reads only this record.

have you some idea?

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

I reckon LRECL=N is what you need.  Notice I remove @@;

data grate;
   infile '~/prova' recfm=N;
   input elab 8. +1 ch $1. +1 sw $1. +1 init 8. +1 fin 8. +1 hourIni 8. +1 hourFin 8. +32;
  
run

View solution in original post

7 REPLIES 7
UrvishShah
Fluorite | Level 6

Can you please define your multiple records in a meaningful way to prepare the SAS Codes from it...

In your post, what all those number represants ??? if you simply want to read one line which contains many variables then use double trailing @@ in your INPUT statement like this...

Input variable_name @@;

-Urvish

reone
Calcite | Level 5

hi,

I can't define the files which I have to read.....

the layout is this:

data-elaboration          8      (aaaammgg)

filler1                         $1

ch                             $1

filler2                         $1

sw                            $1

filler3                        $1

data-initialization         8  (aaaammgg)

filler4                         $1

data-fin                     8 (aaaammgg)

filler5                        $1

hour-ini                    8

filler5                         $1

hour-fin                    8

filler7                        $32

the filler are always missing(' '), and ch or sw can be missing(' ') or one single charachter.

and the files contains only one record:

19941231 C   19950216 19950216 16000000 18300000                                19951231 C T 19960226 19960226 17060000 20150000                                19961130     19961207 19961207 10000000 18000000                                19961231     19970105 19970105 10000000 18000000...............................................................                    ....................................

if you have some idea I'm gratefull...

thanks...

data_null__
Jade | Level 19

This looks about right.

filename FT15F001 temp lrecl=1024;
parmcards;
19941231 C   19950216 19950216 16000000 18300000                                19951231 C T 19960226 19960226 17060000 20150000                                19961130     19961207 19961207 10000000 18000000                                19961231     19970105 19970105 10000000 18000000
;;;;
   run;
  
data grate;
   infile FT15F001;
   input elab 8. +1 ch $1. +1 sw $1. +1 init 8. +1 fin 8. +1 hourIni 8. +1 hourFin 8. +32 @@;
   run;  
reone
Calcite | Level 5

Hi,

can you try with the file which I have attached in this response...

because, my programm don't finish..

data_null__
Jade | Level 19

I reckon LRECL=N is what you need.  Notice I remove @@;

data grate;
   infile '~/prova' recfm=N;
   input elab 8. +1 ch $1. +1 sw $1. +1 init 8. +1 fin 8. +1 hourIni 8. +1 hourFin 8. +32;
  
run
reone
Calcite | Level 5

THANKS!!!!!!!

UrvishShah
Fluorite | Level 6

Try following code...

data want;

   input data_elaboration      8.

         filler1             $1.

         ch                  $1.

         filler2             $1.

         sw                  $1.

         filler3             $1.

         data_initialization 8.

         filler4             $1.

         data_fin            8

         filler5             $1.

         hour_ini            8.

         filler6             $1.

         hour_fin            8.

         filler7             $1. @@;

      cards4;

12345678 C T 12358789 12547898 20145789 4578912

;;;;

Hope it helps...

-Urvish

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
  • 7 replies
  • 1111 views
  • 1 like
  • 3 in conversation