DATA Step, Macro, Functions and more

Produce dataset, placing variables in specific columns (mainframe)

Accepted Solution Solved
Reply
Contributor
Posts: 21
Accepted Solution

Produce dataset, placing variables in specific columns (mainframe)

Produce dataset, placing variables in specific columns (mainframe)

I have a work file with 4 variables, when using PROC PRINTTO SAS puts by variables in columns;

PROC PRINTTO PRINT = output;          

PROC PRINT U DATA = final_report NOOBS;

  VAR date dy job cc1;               

 

Results;

The SAS System                                                        

  date           dy      job                    cc1                                    

12/19/16   MO    PDMGCD97    00000008

12/19/16   MO    PDMGHD68    00002947

Date starts in col 01

Dy starts in col 13

Job start is col 20

Cc1 start in col 32

 

Desired;

The SAS System                    

  date   dy job      cc1                  

12/19/16 MO PDMGCD97 00000008

12/19/16 MO PDMGHD68 00002947

Date starts in col 01

Dy starts in col 11

Job start is col 15

Cc1 start in col 25

 

I can easily do this with DATA _NULL_ but I need to keep the work file. It is needed in the next step. I am using an empty check macro that needs that work file. I can also do this in a sort step but the results of the empty check put alternate text in the dataset and the sort OUTREC messes it up.


Accepted Solutions
Solution
‎12-20-2016 12:45 PM
Contributor
Posts: 21

Re: Produce dataset, placing variables in specific columns (mainframe)

I ended figuring out how to use DATA _NULL_ to get the results I am lookign for. Thank you for the help

View solution in original post


All Replies
Super User
Super User
Posts: 7,988

Re: Produce dataset, placing variables in specific columns (mainframe)

Sorry, why are you writing out a dataset to a text file, and then checking it with a macro?  This:

proc printto print=output;
run;
          
proc print data=final_report nobs;
  var date dy job cc1;
run;  

Seems to be a bit of an odd, maybe old school approach to designing an output report.  If the file is just used to check the dataset look at sashelp.vtable/vcolumn for meta data or explain your "checks".

If you need the file for people to use, then move to proc report, put titles in etc.

Solution
‎12-20-2016 12:45 PM
Contributor
Posts: 21

Re: Produce dataset, placing variables in specific columns (mainframe)

I ended figuring out how to use DATA _NULL_ to get the results I am lookign for. Thank you for the help

PROC Star
Posts: 102

Re: Produce dataset, placing variables in specific columns (mainframe)

If I understand correctly, your problem with the data step is that you have a macro afterwards that uses the name of the last dataset created (stored in _LAST_ option and &SÝSLAST automatic macro variable). 

 

No problem there, doing a DATA _NULL_ step does not change any of those two variables. At least not in the SAS version I am currently testing.

 

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 158 views
  • 1 like
  • 3 in conversation