09-12-2022
Angel_Saenz
Quartz | Level 8
Member since
09-28-2016
- 57 Posts
- 42 Likes Given
- 0 Solutions
- 0 Likes Received
-
Latest posts by Angel_Saenz
Subject Views Posted 1461 09-12-2022 12:04 PM 1543 09-10-2022 03:28 PM 1581 09-10-2022 01:24 PM 1721 02-07-2019 12:23 PM 1722 02-07-2019 12:22 PM 1741 02-07-2019 12:05 PM 809 01-21-2019 07:24 PM 4169 12-26-2018 01:23 PM 1081 12-06-2018 06:49 PM 1702 11-15-2018 02:43 PM -
Activity Feed for Angel_Saenz
- Posted Re: index unique in more than one var on SAS Programming. 09-12-2022 12:04 PM
- Liked Re: index unique in more than one var for Patrick. 09-12-2022 12:04 PM
- Posted Re: index unique in more than one var on SAS Programming. 09-10-2022 03:28 PM
- Posted index unique in more than one var on SAS Programming. 09-10-2022 01:24 PM
- Liked Re: Easy way to comvert ds1 to ds2 for ballardw. 02-24-2019 01:00 PM
- Liked Re: Easy way to comvert ds1 to ds2 for novinosrin. 02-24-2019 12:59 PM
- Liked Re: Easy way to comvert ds1 to ds2 for novinosrin. 02-24-2019 12:59 PM
- Posted Re: Easy way to comvert ds1 to ds2 on New SAS User. 02-07-2019 12:23 PM
- Posted Re: Easy way to comvert ds1 to ds2 on New SAS User. 02-07-2019 12:22 PM
- Posted Easy way to comvert ds1 to ds2 on New SAS User. 02-07-2019 12:05 PM
- Liked Re: proc freq like group by for Astounding. 01-24-2019 01:44 PM
- Posted proc freq like group by on New SAS User. 01-21-2019 07:24 PM
- Liked Re: List of all datasets in a library showing number of observations of each one for novinosrin. 01-07-2019 02:22 PM
- Posted List of all datasets in a library showing number of observations of each one on New SAS User. 12-26-2018 01:23 PM
- Liked Re: round tens for Tom. 12-07-2018 10:47 AM
- Liked Re: round tens for ballardw. 12-06-2018 07:43 PM
- Liked Re: round tens for Jagadishkatam. 12-06-2018 07:43 PM
- Posted round tens on New SAS User. 12-06-2018 06:49 PM
- Posted All datasets of a library with access permission on New SAS User. 11-15-2018 02:43 PM
- Posted Re: variable consecutively counts account_number on SAS Programming. 02-22-2018 05:57 PM
-
Posts I Liked
Subject Likes Author Latest Post 1 1 1 1 1
09-12-2022
12:13 PM
So what you want is that the combination of three variables uniquely identify the observations.
So in terms of sorting you mean something like:
proc sort data=lib1.dataset1 nodupkey ;
by var1 var2 var3;
run;
In terms of indexes that means you want a composite index, an index based on the value or two or more variables.
... View more
02-07-2019
01:47 PM
1 Like
See if this makes you happier:
data have;
input product $ INCOME1 INCOME2;
cards;
A 10 100
A 20 200
B 40 300
B 70 600
B 40 900
C 40 300
C 70 600
C 40 900
;
run;
proc tabulate data=have;
class product;
var income1 income2;
table mean='',product=''*(income1 income2)
/ row=float
;
run;
The mean='' says the row will be a mean value and the ='' suppresses the default label of mean.
The table option row=float removes an empty column created by the suppressed mean label.
You can control the format of the calculated mean by adding *f=<pick your format> after the mean='' part. Example
mean=''*f= f5.0 would display as 5 digits without any decimal portion.
... View more
01-22-2019
03:26 AM
1 Like
See if this comes closer to what you want:
proc freq data=ds;
tables var1 * var2 / missing list;
run;
... View more
12-26-2018
02:34 PM
alternatively with proc sql,
dictionary tables
proc sql;
create table want as select memname, nobs from dictionary.tables where libname='SASHELP';
quit;
... View more
12-06-2018
07:44 PM
3 Likes
No. Here are two algorithms. You could use PROC FCMP to make your own function, but it is probably NOT worth the effort.
data test;
input have @@;
test1=round(have,100);
test2=100*int(have/100);
test3=have-mod(have,100);
cards;
111 1499 15251
;
Obs have test1 test2 test3
1 111 100 100 100
2 1499 1500 1400 1400
3 15251 15300 15200 15200
... View more
11-16-2018
03:20 AM
My preferred method is to use an external command to retrieve the information:
%let library=sasuser;
%let library_path=%sysfunc(pathname(&library));
filename dirlist pipe "ls -l &library_path/";
data attributes;
label
number = '#'
dsname = 'Name'
memtype = 'Member Type'
size = 'File Size'
mod_date = 'Last Modified'
mod_time = 'Time'
permissions = 'Access Permission'
;
infile dirlist;
input
permissions :$10.
links :3.
user :$8.
group :$8.
size :15.
_month :$3.
day :2.
year_time :$5.
dsname :$254.
;
retain number 0;
dsname = scan(dsname,-1,'/');
extension = scan(dsname,2,'.');
dsname = scan(dsname,1,'.');
if permissions ne 'total'; /* removes header */
if extension in ('sas7bdat','sas7bvew','sas7bcat');
length memtype $10;
select (extension);
when ('sas7bdat') memtype = 'DATA';
when ('sas7bvew') memtype = 'VIEW';
when ('sas7bcat') memtype = 'CATALOG';
otherwise;
end;
month = month(input('01' !! _month !! '1960',date9.));
if length(year_time) = 5
then do;
if month > month(today())
then year = year(today()) - 1;
else year = year(today());
mod_time = input(year_time,time5.);
end;
else do;
year = input(year_time,4.);
mod_time = 0;
end;
mod_date = mdy(month,day,year);
format
mod_date yymmddd10.
mod_time time5.
;
number + 1;
keep number dsname memtype size mod_date mod_time permissions;
run;
proc print data=attributes noobs label;
var number dsname memtype size mod_date mod_time permissions;
run;
... View more
02-22-2018
05:57 PM
Let me try it SuryaKiran, I accepted other your answer, thanks a lot
... View more
09-28-2017
01:37 PM
SQL is definitely easier than DATA step for this task.
But if you are confident that dataset 2 always has exactly 3 observations for each value of the matching var (var1 in your example), you can make a relatively simple data step, using the POINT= option is a SET DATASET2 statment:
data want (drop=_:);
set dataset1;
by var1;
_group+first.var1;
do p= 3*_group-2 to 3*_group;
set dataset2 (rename=(var2=var3)) point=p;
output;
end;
run;
Now think about the complexities neither dataset has a fixed number of observations per record. You may not want to go there.
... View more
09-26-2017
04:52 PM
@Angel_Saenz: The code, as is, will accomodate any number of records in either of the two datasets. Until you discover what value provides false positives, you could always sort the resulting file by
var_street number score
and then, possibly, only keep the record (for each var_street number) with the lowest score.
Art, CEO, AnalystFinder.com
... View more
03-22-2017
11:52 AM
the findc function allows you to both find if a string contains one or more of the variables in a list, as well as ignore case (if desired). e.g.:
data want; informat string $23.; input string &; if findc(string, 'abc', "i") then want='Contains A, B or C'; datalines; Microsoft Office Visio Microsoft Office Word Adobe Photoshop Adobe PhotoshopPro Internet Explorer ;
Art, CEO, AnalystFinder.com
... View more
03-06-2017
02:50 PM
1 Like
On the other hand, if you're on a system that can run VB Script (e.g., any version of Windows) you can use SAS to create an Excel pivot table for you. For some sample code, take a look at: https://listserv.uga.edu/cgi-bin/wa?A2=ind0506a&L= SAS-L&O=D&F=P&X=FB41D225061C8C7F9B&P=62191
Art, CEO, AnalystFinder.com
... View more
02-28-2017
11:12 PM
1 Like
Your problem description talks about dates, and not datetimes. To get dates only, you could use:
date_1_converted = input(date1, ddmmyy10.);
date_2_converted = input(date2, ddmmyy10.);
format date_1_converted date_2_converted yymmdd10.;
There's no need to apply YYMMDD10 as the final format. That's just an example of what is possible.
Also note, it's not 100% clear that DATE_2_CONVERTED should apply the DDMMYY10 informat to convert it. That would be applicable when the character values actually include the day then the month then the year. But it's also conceivable that the character values contain the month then the day then the year. In that case, convert with:
date_2_converted = input(date2, mmddyy10.);
... View more
02-14-2017
03:59 PM
1 Like
@Angel_Saenz - you ask for: "I need 1 obs by ID1 and ID2 together, how can I do it?"
Then the code should be:
data dsn_out;
set dsn_in;
by ID1 ID2;
if first.ID2;
run;
... View more
02-14-2017
01:43 PM
Using the example data that @ballardw provided, something like the following would work:
libname lib 'c:\art';
data lib.one;
input id $ x;
datalines;
a 13
b 14
c 15
;
data lib.two;
input id $ x;
datalines;
b 23
c 24
d 25
;
data combined;
merge
lib.one (in=a keep=id x rename=(x=_x))
lib.two (in=b)
;
by id;
if a and b;
dif=x-_x;
run;
run;
HTH,
Art, CEO, AnalystFinder.com
... View more
02-13-2017
02:04 PM
thank you Tom I think DBMS=EXCEL option include xls, but I ned use DBMS=XLS as you told me
... View more