I am having weird issues in SAS - sas

I need to write SAS code that divides the dataset into separate groups: With my code I get a extra period. I am not sure what I am missing. Could I have someone look at my code?

Related

Convert to STATA from other program?

I'm trying to convert SAS code to STATA and am encountering some difficulty. Is there an add-in that could do this for me? While I'm new to STATA I don't even have SAS and am unfamiliar with its rules.
Here is the first snippet of SAS code that is a problem:
Libname library 'C:\COFUL\LIB\'; Proc format lib=library;
Value $RCOMT
"D43"="NONE" /*NONE*/
"Z20"="LIT" /*LIT
;
Doing language translation from SAS to something else is hard: there is no getting around that. I have done SAS to C# and it is challenging. You need to know both, as Nick stated. You won't easily find a copy of SAS to use. Check with SAS for a University or Learning edition. That will be limited in the number of obs (recs). SAS is comprised of 2 main things: data steps and procs. These are known as step boundaries. The data step is a very powerful DO/WHILE loop. Procs are a separate beast.
Why would you want to convert to Stata? You would have better luck converting to Python. Read Randy Betancourt's book on Python for SAS users. That would be a start. If you have to use Stata, I am not aware of anyone doing that.

How do I make different formatting e.g., bold, italics etc to Excel files within SAS?

I am trying to change formatting within an excel spreadsheet using SAS.
However, being a complete beginner to SAS, not sure how to go about it.
Googling lots made me get 'ODS Excel' and 'ODS Excel XP' as possible approaches.
'ODS Excel' is giving me corrupted files though, so I'm skipping that one.
Could someone please advise in detail on how to do something like below within each step I have written, preferably using 'ODS Excel XP'? Or if I am doing something wrong with 'ODS Excel' in my syntax, happy to use that as well.
Input file: /myfile.excel/
SAS:
Step 1: Read myfile.excel, which looks like this
Step 2: Turn the title row into bold text and that whole row yellow in colour, not just the cell with the text
Step 3: Output the formatting changes to new or existing excel, I don't really care
I have no idea how to do this in SAS. Could someone help, please?
Thank you!
Update: This is my SAS version: Custom Version 9.4_M3

How do I get SAS to ignore missing variable names?

If a SAS DATA step references a non-existant variable in a DROP, KEEP, or RENAME statement, it returns an error saying such and stops the DATA step due to this error.
How do I get SAS to keep going with the step when it references a non-existent variable? I assume there's an OPTION for this (?) but I can't figure out what it's called if this is the case.
(I'm dealing with yearly datasets for which variables occasionally get added or deleted from year to year.)
Try using:
options dkricond=nowarn dkrocond=nowarn;
First one is for input datasets, second one is for output datasets.
You might want to set these back to warn or error after you are done with the specific data steps where you know this will be an issue.
SAS Manual page

Prevent SAS EG from outputting every dataset in datastep

I'm new to SAS EG, I usually use BASE SAS when I actually need the program, but my company is moving heavily toward EG. I'm helping some areas with some code to get data they need on an ad-hoc basis (the code won't change though).
However, during processing, we create many temporary files that are just iterations across months. I.E. if the user wants data from 2002 - 2016, we have to pull all those libraries and then concatenate them with our results. This is due to high transactional volume, the final dataset is limited to a small number of observations. Whenever I run this program though, SAS outputs all 183 of the datasteps created in the macro, making it very ugly, and sometimes the "Output Data" that appears isn't even output from the last datastep, but from an intermediary step, making it annoying to search through for the 'final output dataset'.
Is there a way to limit the datasets written to "Output Data" so that it only shows the final dataset - so that our end user doesn't need to worry about being confused?
Above is an example - There's a ton of output data sets that I don't care to see. I just want the final, which is located (somewhere) in that list...
Version is SAS E.G. 7.1
EG will always automatically show every dataset that was created after the program ends. If you don't want it to show any intermediate tables, delete them at the very last step in your process.
In your case, it looks as if your temporary tables all share the name TRN. You can clean it up as such:
/* Start of process flow */
<program statements>;
/* End of process flow*/
proc datasets lib=work nolist nowarn nodetails;
delete TRN:;
quit;
Be careful if you do this. Make sure that all of your temporary tables follow the same prefix naming scheme, otherwise you may accidentally delete tables that you need.
Another solution is to limit the number of datasets generated, and have a user-created link to the final dataset. There's an article about it here.
The alternate solution here is to add the output dataset explicitly as an entry on your process flow, and disregard the OUTPUT window unless you need to investigate something from the intermediary datasets.
This has the advantage that it lets you look at the intermediary datasets if something goes wrong, but also lets you not have to look through all of them to see the final dataset.
You should be able to add the final output dataset to the process flow once it's created once easily, and then after that one time it will be there for you to select to look at.

How can i write the results of SAS fullstimer option to a dataset?

We are evaluating the time taken for two set of codes in SAS. Is there a way we can write/ tabulate option fullstimer results in a SAS dataset, without copying the entire log file into a notepad?
I would go about it like this.
Create separate SAS program files containing your code for each approach. Include options fullstimer at the top of both.
Batch submit your programs and write the logs to permanent files using the -log command line option.
Create a simple program that reads in both logs and compares the results.
The last step can be accomplished by using data steps with the INFILE statement and restricting the input records to those which are standard output from FULLSTIMER. Then you can compare the created datasets however you wish, e.g. via PROC COMPARE.
SAS has provided a log parsing macro that looks as though it should do the sort of thing that you want. It's available here:
http://support.sas.com/kb/34/301.html