BookmarkSubscribeRSS Feed
xavpontes
Fluorite | Level 6

I am new to sas macro. If you know of a good book or resource to help me speed up my knowledge please share.

I am trying to download a mainframe file into MS Access to this address C:\2016\Access as a sas data set called

tgcont.  Please review my program and make any corrections.  Thank you.

/* Program Name MACRO_LOAD_TGCONT */

%MACRO LOAD_TGCONT();

 

 DATA TGCONT;

   INFILE TGCONT MISSOVER;

   INPUT @01   SSN $CHAR9.

  ;  

RUN;

 

PROC SORT DATA=TGCONT OUT=CONTROL.TGCONT NODUPKEY;

   BY

     SSN                 

     ;

RUN;

%MEND;

6 REPLIES 6
Kurt_Bremser
Super User

Since you do not use macro logic, the macro is not necessary at all.

 

If you encounter problems, post the log, including the filename and libname declarations for fileref TGCONT and library CONTROL, respectively.

xavpontes
Fluorite | Level 6

Thank you for your reply. You said macro isn't necessary. Please share your solution. Thanks.

Astounding
PROC Star

Just for us to have anything to look at, you would have to remove two lines from the program (the lines that begin with %MACRO and %MEND).  Then run what you have and see what you get.

 

It would be helpful to see the DD statements that define TGCONT and CONTROL.  Or if there are no DD statements, the SAS statements that define them.

 

It would also be helpful to know what SAS software you have that would let a mainframe write to a PC.  The two would not normally be connected without additional software.

 

Eventually you may need a macro to make the program more flexible.  Right now, you just need a working program without any macro language.

xavpontes
Fluorite | Level 6

Thank you for your reply.  Even without the %macro and %mend, I don't see this code working. From your answer,

I could ftp the mainframe file to the PC as a text file. And how would I write it to a folder as sas data set? Thanks. 

Astounding
PROC Star

The structure of a SAS data set is different on a mainframe than on a PC.  So the process you are expecting has to change.

 

If TGCONT represents a text file (as it would if you were to INPUT variables from it), there is no reason to move it to a SAS data set first.  Just move text from the mainframe to the PC, then use a SAS program on the PC to create a SAS data set there.

 

If TGCONT represents a SAS data set, you would probably use a SAS program to dump it to a text file. (Alternatively, use a SAS program to download it to a SAS Transport file, but let's hold off on that conversation.)  Then use the above steps.

 

So far, it's difficult to know what you are starting with.  What is in TGCONT?

Kurt_Bremser
Super User

@xavpontes wrote:

Thank you for your reply.  Even without the %macro and %mend, I don't see this code working. From your answer,

I could ftp the mainframe file to the PC as a text file. And how would I write it to a folder as sas data set? Thanks. 


To repeat myself:

 

If you encounter problems, post the log, including the filename and libname declarations for fileref TGCONT and library CONTROL, respectively.

 

AND I MEAN IT!

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