62 Answered Questions for the topic SAS
Sas Type Conversion
SAS : Convert character to numeric without creating another variable?
I want to convert `x` to numeric. DATA test; input x $1.; cards; 1 2 0 ; run; I tried different ways : - With `*1` : /* trial1 */ DATA test1; SET test; x = x*1; run; The log... more
How to call one macro program from another in SAS Enterprise Guide?
Is there any macro command that allows calling one program from another (the `%run_program()` pseudo code)? Program "Settings": %let myvar="HELLO WORLD!"; Program "Program": ... more
Sorting an almost sorted dataset in SAS?
I have a large dataset in SAS which I know is almost sorted; I know the first and second levels are sorted, but the third level is not. Furthermore, the first and second levels contain a large... more
Join overlapping date ranges?
I need to join table A and table B to create table C. Table A and Table B store status flags for the IDs. The status flags (A_Flag and B_Flag) can change from time to time, so one ID can contain... more
SAS: rearrange field order in data step?
In SAS 9, how can I in a simple data step, rearrange the order the field. Data set2; /*Something probably goes here*/ set set1; run; So if set1 has the following fields: Name Title Salary ... more
Treat missing values as zero in SAS where clause?
Is there an equivalent of the Oracle NVL function in SAS? For example, if I have a where clause in SAS that says: where myVar > -2; it is not going to include any rows that have myVar =... more
Opening SAS datasets for viewing from within a .sas program?
Is there a way to open a SAS dataset for viewing (i.e., in the "ViewTable" window) from within a .sas file?
How to remove duplicated records\\observations WITHOUT sorting in SAS？
I wonder if there is a way to unduplicate records **WITHOUT** sorting?Sometimes, I want to keep original order and just want to remove duplicated records. Is it possible? BTW, below are what I... more
In SAS, what is the difference between Proc Means And Proc Summary?
What exactly is the difference between Proc Means and Proc Summary? Many sites state that both these are same, but unless each has something unique will SAS create it?
For in loop equivalent in SAS 9.3?
I'm searching for a while an equivalent of the ***for in* loop** (like in [Python] or in R) in SAS 9.3 macro language. The [DO loop] seem's to be the solution but did't work exactly as I... more
Is it possible to loop over SAS datasets?
I have 60 sas datasets that contain data on consumers individual characteristics such as `id, gender, age, amountSpent, ....` Each dataset shows data only for one time period (data1 is Jan, data2... more
Quit vs Run statements in SAS?
In SAS, what is the difference between 'quit' and 'run'? statements? I cannot figure out when to use 'quit' and when to use 'run'? For example, why is `proc datasets` using `quit` but `proc... more
Changing Value of Macro Variable inside SAS macro?
I am defining a macro variable inside a macro. Then, I am feeding it into a second macro. Inside macro2 counter changes value to 200. However, when I check what is inside the macro variable that I... more
How to delete blank observations in a data set in SAS?
I want to delete ALL blank observations from a data set. I only know how to get rid of blanks from one variable: data a; set data(where=(var1 ne .)) ; run; Here I set a new data set without... more
In SAS, what are good techniques/options for catching syntax errors?
In the enhanced editor, the coloring might give you a hint. However, on the mainframe I don't believe there is anything, in the editor, that will help you. I use OPTIONS OBS=0 noreplace; The... more
Open SAS .egp file to view code witout having SAS installed?
is there any solution to open SAS .egp file without having SAS installed on my pc? i need to open project.egp to check my old code but i dont have SAS anymore so is there any other way to do that?
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; ... more
Do I need to call rollback if I never commit?
I am connecting to a SQL Server using no autocommit. If everything is successful, I call commit. Otherwise, I just exit. Do I need to explicitly call rollback, or will it be rolled back... more
how to concatenate each record within one observation in SAS?
I wonder whether it's possible to concatenate each record within one observation with SAS code. E.g. Here is the original data set **1st_name 2nd_name 3rd_name .....last_name** abc def ghi... more
How can I read a SAS dataset?
I have a lot of files in SAS format, and I'd like to be able to read them in programs outside of SAS. I don't have anything except the base SAS system installed. I could manually convert each one,... more
Sas Proc Sql
Limiting results in PROC SQL?
I am trying to use PROC SQL to query a DB2 table with hundreds of millions of records. During the development stage, I want to run my query on an arbitrarily small subset of those records (say,... more
Finding strings that differ with at most one letter from a given string in SAS with PROC SQL?
First some context. I am using proc sql in SAS, and need to fetch all the entries in a data set (with a couple of million entries) that have variable "Name" equal to (let's say) "Massachusetts". Of... more
SAS memory usage and sorting?
I'm curious about SAS's use of memory, sorting, and why it seems to be so inefficient. I have a quad core xeon with 8GB ram. I have a 3GB dataset. Why, at any given time during a standard proc... more
SQL/SAS: Best performance for selecting from big table (2bn rows)?
I have a non-indexed 2 billion rows table in a read-only SAS SPD server (**bigtable**). I have another 12 million rows table in my workspace (SAS_GRID) with a single column of unique ids... more