DATA Step, Macro, Functions and more

Sas Macro

Reply
Occasional Contributor
Posts: 9

Sas Macro

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;

Super User
Posts: 7,803

Re: Sas Macro

Posted in reply to xavpontes

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 9

Re: Sas Macro

Posted in reply to KurtBremser

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

Super User
Posts: 5,509

Re: Sas Macro

Posted in reply to xavpontes

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.

Occasional Contributor
Posts: 9

Re: Sas Macro

Posted in reply to Astounding

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. 

Super User
Posts: 5,509

Re: Sas Macro

Posted in reply to xavpontes

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?

Super User
Posts: 7,803

Re: Sas Macro

Posted in reply to xavpontes

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!

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 6 replies
  • 493 views
  • 1 like
  • 3 in conversation