BookmarkSubscribeRSS Feed
OrourkeBow
Obsidian | Level 7

I have attached a few pictures to help explain. 

But I wanted to have everything I get essentially but in Excel. Also, I will put up a screenshot of old data that was exported long ago. This is the information I need. 

 

But following the code logic you presented

proc export dbms=xlsx data=mylib.PLADATA
  file='/home/u64122702/Output/paxraw.xlsx' replace;
  file='/home/u64122702/Output/perday.xlsx' replace;
  file='/home/u64122702/Output/perminute.xlsx' replace;
  file='/home/u64122702/Output/summary.xlsx' replace;
  file='/home/u64122702/Output/reports2/_invalid_data_characters.xlsx' replace;
  file='/home/u64122702/Output/reports2/_invalid_inten_step.xlsx' replace;
  
run;

could I add code like this?

I also separated the code into 4 parts, based on how its set up, like step 1-4, with each as a separate program. 

 

When I run the code above (even with just per day) I get an error for the mylib command - see log below: 

OTE: The previous statement has been deleted.
 NOTE: The previous statement has been deleted.
 NOTE: The previous statement has been deleted.
 NOTE: The previous statement has been deleted.
 NOTE: The previous statement has been deleted.
 251          file='/home/u64122702/Output/perday.xlsx' replace;
              ____
              180
 252          file='/home/u64122702/Output/perminute.xlsx' replace;
              ____
              180
 253          file='/home/u64122702/Output/summary.xlsx' replace;
              ____
              180
 254          file='/home/u64122702/Output/reports2/_invalid_data_characters.xlsx' replace;
              ____
              180
 255          file='/home/u64122702/Output/reports2/_invalid_inten_step.xlsx' replace;
              ____
              180
 ERROR 180-322: Statement is not valid or it is used out of proper order. 
 256        
 257        run;
 
 ERROR: Libref MYLIB is not assigned. NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE EXPORT used (Total process time):
       real time           0.00 seconds
       user cpu time       0.01 seconds
       system cpu time     0.00 seconds
       memory              914.37k
       OS Memory           27280.00k
       Timestamp           01/16/2025 07:41:35 PM
       Step Count                        391  Switch Count  0
       Page Faults                       0
       Page Reclaims                     150
       Page Swaps                        0
       Voluntary Context Switches        4
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           8
       

I will put a screenshot of the directory. I made a "reports2" folder to send this testing there and the pic of the output I need (and they want in a rush, ffs lol). 

 

Thanks!!!Screenshot 2025-01-16 at 3.04.25 PM.pngScreenshot 2025-01-16 at 3.03.28 PM.png

Tom
Super User Tom
Super User

 

A little SAS 101.

 

You normally reference datasets with either one or two level names.  

When you use a two level name like A.B then A is the LIBREF and B is the member name.  When you use a one level name normally the LIBREF part is assumed to be WORK. 

 

A libref is a nickname you create that allows you to reference datasets in various "libraries".  You will always have a WORK library defined for temporary datasets that disappear when the SAS session ends.  You can define other librefs using a LIBNAME statement.  Typically a libref statement is in the form:

libname mylib 'location of folder';

 

Your current code most likely already has a libname statement to define a libref that points to the folder where it wrote those SAS datasets.  So use that libref instead of the MYLIB name that I used in my example code to show you the syntax. 

 

When you write a proc step in SAS you should include the PROC statement, any other statements the procedure needs to do what you want and then a RUN and/or QUIT statement to signal the end of the step.  Most PROCs , like PROC EXPORT, need a RUN statement.  Some, like PROC SQL, need a QUIT.  Some , like PROC GLM or PROC DATASET, allow both.  The RUN statement indicates that the PROC should do the statements up that point immediately and the QUIT statement marks the end of the whole PROC step.

 

So if you want to run muliple PROC EXPORT steps you need multiple PROC EXPORT statements.

proc export dbms=xlsx data=mylib.paxraw
  file='/home/u64122702/Output/paxraw.xlsx' replace
;
run;
proc export dbms=xlsx data=mylib.perday
  file='/home/u64122702/Output/perday.xlsx' replace
;
run;

Not sure what the pictures show.  One of them I can tell is a WORK dataset name PERDAY.  Remember that WORK datasets disappear when your current SAS sessions ends.  So to reference the dataset in your picture you could use either WORK.PERDAY or just PERDAY.

proc export dbms=xlsx data=WORK.perday
  file='/home/u64122702/Output/perday.xlsx' replace
;
run;

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 31 replies
  • 18523 views
  • 3 likes
  • 3 in conversation