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

Hi Experts,

I want to automat report  to export as following txt format to particular location 

abc_202401

abc_202402

abc_202403

abc_202404

........................

.......................

abc_202412

 

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

Populate macro variable &export_path without quotes to not end-up with double quoting in the file statement.

Patrick_1-1713593198710.png

 

 

View solution in original post

4 REPLIES 4
ballardw
Super User

Details matter.

By "as following text" do you mean make a report that looks like that? Names of files?

By "particular location" do you mean text file folder location? Columns and rows in the text file?

 

Typically when asking about making a report you need to provide examples of the source data and the rules involved in making a report. Unfortunately an example doesn't provide much in the way of the rules needed.

 

You subject line also mentions "import". Import what? what kind of file or data? What type of variables and properties are needed?

pavank
Quartz | Level 8

Hi  ballardw ,

i want automatic for 12 months 

%macro export_files;
    %do month=1 %to 12;
        %let month_suffix = %sysfunc(putn(&month,z2.));
        %let file_name = abc_2024&month_suffix..txt;
        %let export_path = "/home/u35263349/My_Folder/export_classdatasett"; /* Specify your export path */
        
        /* Your data step or procedure to create the dataset to be exported */
        data _null_;
            file "&export_path.\&file_name";
            put "This is data for month &month_suffix.";
        run;
    %end;
%mend;

%export_files;
Patrick
Opal | Level 21

Populate macro variable &export_path without quotes to not end-up with double quoting in the file statement.

Patrick_1-1713593198710.png

 

 

PaigeMiller
Diamond | Level 26

@pavank wrote:

Hi  ballardw ,

i want automatic for 12 months 

%macro export_files;
    %do month=1 %to 12;
        %let month_suffix = %sysfunc(putn(&month,z2.));
        %let file_name = abc_2024&month_suffix..txt;
        %let export_path = "/home/u35263349/My_Folder/export_classdatasett"; /* Specify your export path */
        
        /* Your data step or procedure to create the dataset to be exported */
        data _null_;
            file "&export_path.\&file_name";
            put "This is data for month &month_suffix.";
        run;
    %end;
%mend;

%export_files;

And what is wrong with this code? Please explain in detail. If there are errors in the log, please show us the log.

--
Paige Miller

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 4 replies
  • 380 views
  • 0 likes
  • 4 in conversation