I have a particular report that I am asked to run from time to time. The details are slightly different each time - different date ranges, different selection criteria - but structurally, the report is fairly stable. I do make some structural changes from time to time, however.
I have two hopes for these reports:
1) to be able to rep...
Here is my Input:
ID Color
1 green
1 red
1 orange
1 green
1 red
2 red
2 red
2 blue
3 green
3 red
Here is what I want in my output - a count of records by ID for each color:
ID green red orange blue
1 2 2 1 0
2 0 2 0 1
3 1 1 0 0
I know I can get the information u...
I connect to an SQL Server 2005 DB from SAS 9.2 via SAS/Access ODBC Driver.
In the DB, I have a table my_table, which has an INSERT-trigger that copies all the inserted rows into another table in the database. In the SQL Server environment, the trigger works normally. However, SAS Proc SQL doesn't seem to get on well with a table with t...
Is there a shortcut in Base SAS to provide focus to the command-line / display manager bar?
...
I have 36 completely independent queries I need to run on a regular bases which would go much faster if they could run 3 at a time (the database cancels our queries if we try and do more than 3 at a time) instead of each one waiting for the previous to finish.
I would like to do something like this
/* Some prep code here*/
/* Launch b...
A csv file I am trying to read with SAS has spaces between fields with double quotes.
example:
"ok","bad spaces ahead" ,"more data"
_______________________^spaces^____________
How do I get SAS to read this correctly? Do I need to have the csv replaced?
...
I found this paper on SAS that includes (on the first page and some other parts) the following line of code:
if trt1pn > .z then...
I was wondering what the purpose of it can be. I had never seen the ".z" expression before. I though (and some colleagues of mine thought the same) it was a typo. But you can do
data kk;
a = .z;
b ...
How can I export a character variable WITH trailing spaces and quotes?
eg:
data x;
format x $quote17.;
x='ruby';
put x=;
run;
(log extract)
x="ruby"
What is the most efficient way to get the following result?
x="ruby "
...
How do I determine the number of CPU cores the PC using code? Is there a way to do it in SAS. I want to determine the number of cores and then set how many threads I should run.
...
I have written some SAS code that calls R via the x command (I am using SAS 9.1.3 so there is no native SAS interface to R).
OPTIONS XWAIT XSYNC;
X """&r_path."" --no-save --quiet < ""&out_code_folder.\code.r"" > ""&out_code_folder.\abba.log""";
This code works correctly when I run it in the SAS IDE but when I try to run the same cod...
I got a file in this format.
abc;def;"ghi
asdasd
asdasd
asd
asd
aas
d
"
Now I want to import it with SAS. How do I handle the multiline values?
...
Hi,
Can anyone tell me what is the fastest way to programmatically convert a SAS dataset into a CSV file. I know I can use a data step and output to a file etc. But is that the only way?
Thanks,
Adnan.
...
I ran the same probit regression in SAS and R and while my coefficient estimates are (essentially) equivalent, the reported test statistics are different. Specifically, SAS reports test statistics as t-statistics whereas R reports test statistics as z-statistics.
I checked my econometrics text and found (with little elaboration) that it...
Hi,
How do I read a data file one row at a time in SAS?
Say, I have 3 lines of data
1.0 3.0 5.6 7.8
2.3 4.9
3.2 5.3 6.8 7.5 3.9 4.1
I have to read each line in a different variable. I want the data to look like.
A 1.0
A 3.0
A 5.6
A 7.8
B 2.3
B 4.9
C 3.2
C 5.3
C 6.8
C 7.5
C 3.9
C 4.1
I tried a bunch of things.
If it has a variabl...
This is related to calling C functions (made into dynamic libraries) from SAS. There are 4 files. the first 2 (1 c-file and 1 sas-file) are a positive control using doubles. The remaining files are the problematic.
C-FILE-1
#ifdef BUILD_DLL
#define EXPORT __declspec(dllexport)
#else
#define EXPORT __declspec(dllimport)
#endif...
I have XML files containing multidimensional arrays of numeric data and I need to read them into SAS.
To make files smaller, the format has been specified so that the data are stored in an one-dimensional CDATA array.
To get an idea of the structure of the files, consider something like this:
<!-- Metadata -->
<table name=foo>
<axis i...
I am a tester and i need to compare two data sets structure (not table data) in SAS.
I tried to use 'proc compare' but it compares the data. i want to compare dataset/table structure (column name, data type, null constraints etc.)
Can any one pl help.
thanks
...
I have the following macro:
%macro export_set_excel(data,tabname);
PROC EXPORT DATA= &data. OUTFILE= "&results." DBMS=EXCEL REPLACE;
SHEET=&tabname.;
RUN;
%mend export_set_excel;
My problem is that sometimes this macro doesn't delete the tab if it already exists. Is there anyway, from SAS, that I can check if...
What is the uniqueness and advantage of SAS MACROs over SAS procedures? If macro's purpose is to reduce the effort to repeat tasks for different inputs, can't this be done by written as procedures too?
...
PROC FCMP requires a three-level argument when specifying the output dataset in which the compiled function/subroutine should be stored.
But when using those compiled functions SAS requires a two-level argument for the global option CMPLIB.
The documentation says:
Note: Subroutine and function names must be unique within a package. ...