Hi kushiwije,
Can you provide a clearer example? How does your dataset look at the moment?
It would help us identify the crux of the problem if you can provide a brief illustration of how your data is, and how you want it to be.
Thanks
Hi STrookie,
The month function will return the integer month from a SAS date. So you can subset for dates not on the 9th month:
*display dates not in September(month 9) ;
if month(nipr_exp_dt1) ne 9 ;
Hi Tariq,
When creating the dataset you have the ability to password protect aspects of it. For example, you can set separate passwords for reading, writing and altering the dataset/view. Alternatively, you can use the pw keyword to assign a full lock on your dataset.
data...
Hi Chris,
As far as I know, the SAS do loop is comparable to the C for loop. Syntatically it is a bit different.
For eg. The C for loop:
#include<stdio.h>
int main()
{
int i;
for (i = 0; i < 10; i++)
{
printf ("Hello\n");
printf ("World\n")...
Hi Chris,
You almost have it with your last row, but why the looping?
if mod(i,3) = 1 then reset, otherwise add 1
data iris1;
input m1-m4 @@;
count ++ 1;
if mod(_n_,3) = 1 then count = 1;
cards;
5.1 3.5 1.4 0.2 7.0 3.2 4.7 1.4 6.3 3.3 6.0 2.5
4.9 3.0 1.4 0.2 6.4 3.2 4.5...
Hi Chris,
Try placing the dsd option on the infile line. The dsd option will treat two consecutive delimiters as a missing value. I would also add the missover option in case you have missing values at the end of the line.
data test1;
infile datalines dsd missover ;
input n1 n2 n3 ...
Try using last.
data have ;
input name :$1. dateperiod :$6. ;
cards ;
A 200301
A 200901
A 201001
B 200801
B 200901
B 201001
;;;;;
data want ;
set have ;
by name notsorted ;
if last.name ;
run;
proc print;run;
Not something that I would try to solve with Macro, but definately better handled with the datastep or SQL.
Here is an approach that uses a cartesian product (compare every record with every other record), and then whittles the list down based on the criteria you mentioned above. We get some...
SAS has many was to do this type of thing. Here is an example using proc summary/means
data have ;
input Group ID Successes ;
cards ;
1 1 3
1 2 10
1 3 4
2 1 3
2 2 8
2 3 2
3...
Hi Sap1958,
Before you go any further, please note that:
Age = intck('year',datepart(Birthdate),date());
is the incorrect way to calculate age in SAS as it won't provide the correct age if the day of birth is after todays day.
For example, try running the following code and see if it...
As you have already noted, given the names of your variable, you cannot rename with a variable list.
I would consider using a combination of SQL and the dictionary tables to generate the rename code.
Example using sashelp.class
data have ;
set sashelp.class ;
run;
proc sql noprint...
You can't "convert" anything to currency as there are only 2 datatypes in SAS: Numeric and Character. You can however, permanantly associate a format to display that variable as currency.
Simply replace 'put' with 'format' in your example.
data tblCustomer1;
set tblCustomer;
if Salary...
If CE_DUE_DT has to always be the last day of the previous month (relative to the date being passed to it), I would recommend using the Intnx function to get the first day of that month and subtract 1 to get the last day of the previous month.
Example
data _null_ ;
date = '01SEP10'd ...
Hi Riskassure,
This is look-ahead code.
The ++ performs the same operation as +. Some programmers prefer to use this syntax on sum statements so that it stands out. Consequently _n_ +_n_ < n will work just as well.
The second part of the expression: _n_<n resolves to a boolean value (i.e 1...
Do you want to create blank character variables or numeric variables?
From your first post, I assume you mean numeric variables. SAS uses the period to highlight the missing variable is of type numeric, so other than using a format, I don't think you can change the appearance to a blank in the...
In the normal data step, the trick is to stop SAS from returning to the top of the implicit loop. Metadata attributes get defined at compilation time, so you can define variables with formats, labels and lengths without having any records.
data step:
data blank1 ;
dummy1 ='';
dummy2 =...
Hi,
For your particular issue, I would try a subquery like this
proc sql;
select id,
(select address
from tab_b b
where b.id = a.id
having max(date)=date
) as last_address
from tab_a a;
Here is some test data and code I used to get the last sale...
Hi Chris,
Hopefully this is what you are looking for (one of many ways):
First transposing, then getting the unique group/counts and using proc summary to perform the counts. The completetypes and classdata options allow proc summary to retrieve the groups that have 0 codes.
data have ...
The first thing I would do, is to check why date_num is being recognised as a character datatype. The most likely culprit is a length statement with $.
You can determine the variable type at run time with the vType function (returns C for character variables, and N for numerics). This should...
Don't know much about DDE, but normally if I had to do some heavy VBA manipulation, I prefer to code in the spreadsheets VBA editor directly.
You can however use the ODS Excel tagset to create the named tabs. You might want to read up on the styles you can use with this for further...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.