sas

SQL: Alternative to "First" function?

I'm trying to write a query I don't want to have Cartesian products on. I was going to use the First function, because some Type_Codes have multiple descriptions, and I don't want to multiply my dollars. Select Sum(A.Dollar) as Dollars, A.Type_Code, First(B.Type_Description) as FstTypeDescr From Totals A, TypDesc B Where A.Type_C...

Can I change the execution order of the CALL EXECUTE stack in SAS?

I'm using SAS 9.1.3 to call a macro in a DATA step, but the macro generates a PROC REPORT step, so I am using CALL EXECUTE to call it, generate all those PROC REPORT steps, and then execute them all after the DATA step. I'm using an array, and the macro is executed each time for every element in this array: DATA macro_test; ARRAY que...

excel with an SAS engine

is it possible to run excel with an SAS engine and run SAS code on it? the purpose of this i want to learn SAS a little bit and i dont want to buy it, so maybe i could use it through excel? ...

sas informat datetime

Can anyone advise on the appropriate SAS informat to read in a datetime (dd/mm/yyyy hh:mm) ??? eg data _null_; informat from_dt datetime????.; input from_dt ; put from_dt=; cards; 01/01/1960 00:00 ;run; ...

How can I make a character variable equal to the formatted value of a numeric variable for arbitrary SAS formats?

If I have a numeric variable with a format, is there a way to get the formatted value as a character variable? e.g. I would like to write something like the following to print 10/06/2009 to the screen but there is no putformatted() function. data test; format i ddmmyy10.; i = "10JUN2009"d; run; data _null_; set test; i_formatt...

Using SAS Macro to pipe a list of filenames from a Windows directory

I am trying to amend the macro below to accept a macro parameter as the 'location' argument for a dir command. However I cannot get it to resolve correctly due to the nested quotes issue. Using %str(%') does not work, neither do quoting functions for some reason. The macro will work fine when the filepath has no spaces (eg C:\temp\wit...

Can you use a SAS dataset as a SSIS data source?

We have a some ETL processes that read CSV files that are output from SAS programs. I'm in the process of upgrading one of these ETLs and was wondering if I could use SSIS to read directly from the SAS dataset. Has anybody done this successfully? ...

sas macro index or other?

I have 169 towns for which I want to iterate a macro. I need the output files to be saved using the town-name (rather than a town-code). I have a dataset (TOWN) with town-code and town-name. Is it possible to have a %let statement that is set to the town-name for each iteration where i=town-code? I know that I can list out the town-...

SAS informat datetime milliseconds

Can SAS store and use datetimes that contain fractions of less than 1/10th of a second? eg: data _null_; input @1 from_dt:datetime22.; put from_dt= ; cards; 24Sep2009:11:21:19.856 ; run; ...

SAS macro include guards

In other programming languages such as C++, include guards are used to prevent multiple inclusions of the same code. Like this in C++: #ifndef FOO_INCLUDED #define FOO_INCLUDED .... #endif Does it make sense to build inclusion guards into your SAS macro function definitions? And how should it be done? ...

Is there a way to detect when you've reached the last observation in a SAS DATA step?

Is there a way to check how many observations are in a SAS data set at runtime OR to detect when you've reached the last observation in a DATA step? I can't seem to find anything on the web for this seemingly simple problem. Thanks! ...

avoid "Getting started with SAS" window when opening second SAS session

How can the popup window ("getting started with sas") be prevented from displaying when opening a second SAS session (ie when a 'work' profile is used that does not contain your normal settings) ??? running proc options internal; run; reveals the TUTORIALDLG option, but I do not know the syntax to set this option at 'invocation' - (...

How is π calculated within sas?

just curious! but I spotted that the value of π held by SAS is in fact incorrect. for instance: data _null_; x= constant('pi') * 1000000000000000000000000000; put x= 32.; run; gives a π value of (3.)141592653589792961327005696 however - π is of course (3.)1415926535897932384626433832795 ( http://www.joyofpi.com/pi.html ) - to 31 d...

Writing binary files using SAS?

We currently use SAS to import a binary file and run queries on its data. To do this we use the techniques shown on the SAS website. As an example, this is how we read the data: data work.binary_data; infile "&ifName" lrecl=8 recfm=f; input @1 a PIB1. @2 b PIB1. @3 c PIB1. @4 d PIB1. @5 e PIB1. @6 f PIB1...

How can I get PROC REPORT in SAS to show values in an ACROSS variable that have no observations?

Using PROC REPORT in SAS, if a certain ACROSS variable has 5 different value possibilities (for example, 1 2 3 4 5), but in my data set there are no observations where that variable is equal to, say, 5, how can I get the report to show the column for 5 and display 0 for the # of observations having that value? Currently my PROC REPORT o...

Forcing page breaks in proc report

I'm creating a 2-column report in SAS using PROC REPORT inside the ODS PDF statement. My code looks something like this: ods pdf file='/file/here.pdf' columns=2; ods pagestart=now; proc report data=rpt_data nowd missing contents=''; columns a b c; by a; define a /group order=internal; define b /display; define c /display; break after a...

How can I get the installation information about SAS?

When I batch run a SAS program, I want to know where are SAS installed and pass this information to a macro variable. Is there any system option or global macro variable available? ...

Can I get some default/emtpy text to display if a PROC REPORT doesn't generate due to no valid data?

I have a SAS program that loops through certain sets of data and generates a bunch of reports to an ODS HTML destination. Sometimes, due to small sets of data I run these reports for, a certain PROC REPORT will not generate because, for this set of data I'm on, there is no data to report. I get this message for those instances: WAR...

Working with Data.frames in R (Using SAS code to describe what I want)r

I've been mostly working in SAS of late, but not wanting to lose what familiarity with R I have, I'd like to replicate something basic I've done. You'll forgive me if my SAS code isn't perfect, I'm doing this from memory since I don't have SAS at home. In SAS I have a dataset that roughly is like the following example (. is equivalent o...

Does SAS Proc SQL ever use an index when merging

Consider the following (admittedly long) example. The sample code creates two data sets, data one with "key" variables i,j,k and data two with key variables j,k and a "value" variable x. I'd like to merge these two data sets as efficiently as possible. Both of the data sets are indexed with respect to j and k: the index for the first d...