BookmarkSubscribeRSS Feed
zdassu
Quartz | Level 8

I have multiple text files in my personoal folder in SAS

"/home/gandhis7/Drop/" this is the location.

I want to copy the files from this location to another location in SAS. I have the following code to copy the files but this code allows me to do it only one file at a time.

 

your help will be much appreciated in this matter.

 

Data work.UMRPN054694;
Length 
	U01 $3 
	Meter_Point_Reference 8 
	Actual_Read_Date 8
	Meter_Reading_Source $2 
	Meter_Reading_Reason $2 
	Meter_Serial_Number $14 
	Meter_Reading 8
	Meter_Round_The_Clocking 8 
	Convertor_Serial_Number $1 
	Convertor_Uncorrected_Reading $1
	Convertor_Round_the_Clock_Count $1
	Tolerance_Override_Flag $1;
 FORMAT
        U01 $CHAR3.
        Meter_Point_Ref  BEST10.
        Actual_Read_Date YYMMDD10.
        Meter_Reading_Source $CHAR1.
        Meter_Reading_Reason $CHAR1.
        Meter_Serial_Number $CHAR14.
        Meter_Reading    BEST7.
        Meter_Round_The_Clocking BEST1.
        Convertor_Serial_Number $CHAR1.
        Convertor_Uncorrected_Reading $CHAR1.
        Convertor_Round_the_Clock_Count $CHAR1.
        Tolerance_Override_Flag $CHAR1.;
      
    INFORMAT
        U01 $CHAR3.
        Meter_Point_Ref  BEST10.
        Actual_Read_Date YYMMDD10.
        Meter_Reading_Source $CHAR1.
        Meter_Reading_Reason $CHAR1.
        Meter_Serial_Number $CHAR14.
        Meter_Reading    BEST7.
        Meter_Round_The_Clocking BEST1.
        Convertor_Serial_Number $CHAR1.
        Convertor_Uncorrected_Reading $CHAR1.
        Convertor_Round_the_Clock_Count $CHAR1.
        Tolerance_Override_Flag $CHAR1.;

Infile "/home/gandhis7/Drop/PN054694.txt" DLM=',' MISSOVER DSD ;
Input U01 Meter_Point_Reference Actual_Read_Date Meter_Reading_Source 
      Meter_Reading_Reason Meter_Serial_Number Meter_Reading Meter_Round_The_Clocking 
      Convertor_Serial_Number Convertor_Uncorrected_Reading Convertor_Round_the_Clock_Count 
      Tolerance_Override_Flag;
run;

Proc Print data=work.UMRPN054694;
Where U01 = 'U01';
run;
2 REPLIES 2
Reeza
Super User

https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-tex...

 

It sounds like you're trying to import multiple text files into a single dataset. If so, see the link above for step by step instructions on how to do this in a single step. 

zdassu
Quartz | Level 8

Hi Reeza

 

Thank you for your response, However I have been trying to follow the instructions you provided me and i am getting a little bit confused with the lenghs etc. Can you please elaborate a little more. I wamt to move the following files from 1 location in sas to another.

 

for example I would like to move following files from (all variables in the files are the same as my original message)

/home/zzzzzzz7/Drop/

PN054694.txt

PN054695.txt

PN054696.txt

 

Move them to Libref in SAS

 

RichBase

 

Your help in this matter is much appreciated

 

 

 

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
  • 2 replies
  • 667 views
  • 0 likes
  • 2 in conversation