Similar Threads:
1.libref for "work" data sets (one level name): WORK vs USER vs User= option
I thought there was an easy way to determine the libref for "work"
data sets (i.e. those that can be accessed via a one level name), but
I could not find anything on SAS-L or in the on-line doc. Of course,
searching for WORK USER LIBREF can provide a number of non-related
hits (see additonal slightly off topic question at bottom).
I ended up writing the code included below to determine the libname
and memname for one level data set names.
(I need the two level name to extract info from the dictionary tables)
Is there an easier way to figure out the two level name?
=============================================================
%*** get lib & mem;
%macro libmem(in=,lib=_lib,mem=_mem);
%if %scan(&in,2,.)>' ' %then %do;
%*** two level names are easy;
%let &lib=%scan(&in,1,.);
%let &mem=%scan(&in,2,.);
%end;
%else %do;
%*** one level names are more challenging;
%*** if USER option is set, then use it;
%let &lib=%sysfunc(getoption(USER));
%if "&&&lib"="" %then %do;
%*** if no USER option, check USER libref, if there use it;
proc sql noprint;
select distinct libname into :&lib from DICTIONARY.MEMBERS
where libname='USER';
quit;
%*** if no USER libref defined then it must be WORK;
%if "&&&lib"="" %then %let &lib=WORK;
%end;
%let &mem=∈
%end;
%*** upcase for use with dictionary tables;
%let &lib=%upcase(&&&lib);
%let &mem=%upcase(&&&mem);
%put &lib is &&&lib &mem is &&&mem;
%mend;
%libmem(in=sashelp.prdsale);
data prdsale; set sashelp.prdsale(obs=1); run;
%libmem(in=prdsale);
libname USER 'c:\DeleteThisFolder';
data prdsalU; set sashelp.prdsale(obs=1); run;
%libmem(in=prdsalU);
libname altUser 'c:\DeleteThisOneToo';
options user=altUser;
data prdsalO; set sashelp.prdsale(obs=1); run;
%libmem(in=prdsalO);
=============================================================
While looking at the on-line doc I found these:
Files in UNIX System Services can also be specified without a libref.
The following example specifies an HFS file using a relative path:
data 'saswork/two'; x=2; run;
I do not currently have access to a UNIX or OS/390 box, but was
wondering, do data sets accessed in this way show up in the dictionary
tables? And, if so, what do they look like? Just curious. No real need
to know.
Thanks for any assistance or advice,
Tammie
2.customizing SAS session WORK.REGSTRY WORK.PROFILE
Just switched groups to an X-windows UNIX
environment where several SAS programmers share
the same username/password to one server so that
when I fire up SAS I get the message "all
registry and profile changes will be lost". I'm
coming from a PC SAS environment. I checked with
our systems admin if he could set the file
sharing so I could use my individual account. He
declined for security reasons. Not my place to
question the security of sharing username/
password. :)
Anyway, I'm not clear what types of changes get
saved in SASUSER.REGSTRY and which in
SASUSER.PROFILE, eg. custom key settings and
fonts. I started browsing PROC REGISTRY and it
looks like there is an import, export option.
Presumably, I could export my custom WORK.REGSTRY
settings and then import them at the beginning of
each session. I'm a little unclear on the import
because the v9 documentation says SASUSER.REGSTRY
will not be overwritten but it will be "updated"
with any changes from the imported file. This
makes me a little uncomfortable because on the
off chance I am the first one logged in, any
changes will be made to SASUSER.REGSTRY, which
the other programmers might not appreciate.
Alternatively, we could have a little SAS
programmers meeting and come to agreement on
common settings. Hmmmm. Or just lobby the
system admin to let us use individual accounts.
Hmmmm. Being new to the group, I'm not inclined
to go those routes. :)
Any advice, documentation to read? Bill H, Wash
U, St Louis
3.defaulte work library is not "work"
After running following code, the defaulted work directory changed to
"user".
how can I change back it to "work" again?
Thanks.
Jeff
OPTIONS NONOTES NOSOURCE NOSOURCE2;
*option mprint mlogic symbolgen;
%let dir=M:\Users\JP\PM\PM_RF;
%let datasetdir=M:\Users\JP\PM\Participation Study;
%let testids=51,52,53;
%let client = ABB;
%let Period=RF;
%let SvcMths=2;
libname orig "&datasetdir.\datasets";
libname user "&dir.\userInputs";
*libname ret 'N:\PM\Participation Study\Results';
*libname extn odbc uid=&SYSUSERID dsn=mhcdatawh_dev schema=dbo
readbuff=5000;
*
proc* *datasets* lib=user kill;
*
run*;
*
proc* *datasets* lib=work kill;
*
run*;
/*Open definition file*/
options noxwait noxsync;
x '"C:\Program Files\Microsoft Office\Office12\excel.exe"';
*
data* _null_;
x=sleep(*5*);
*
run*;
*;
/* open Excel workbook */
/*"N:\PM\PM_RF\CSVs\definitionT.csv" */
*;
filename ddecmd dde 'excel|system';
*
data* _null_;
file ddecmd;
put "[FILE-OPEN(""&dir.\CSVs\definition.xls"")]";
*
run*;
*;
/* specify desired Excel worksheet cell range */
*;
filename xlin DDE "excel|&dir.\CSVs\[definition.xls]definition!r2c1:r500c3";
*
run*;
*;
/* read Excel files using DDE into SAS data set*/
*;
*
data* user.rfs_labels_all;
infile xlin dlm='09'x notab missover dsd;
informat id *8.* type $20. label $200.;
input id type label;
format id *8.* type $8. label $200.;
*
run*;
*;
/* close Excel workbook and close Excel */
*
data* _null_;
file ddecmd;
put "[FILE-CLOSE(""&dir.\CSVs\definition.xls"")]";
put '[QUIT()]';
*
run*;
/*********************************************
*********************************************
*********************************************/
/*Open codesetmap excel file*/
x '"C:\Program Files\Microsoft Office\Office12\excel.exe"';
*
data* _null_;
x=sleep(*5*);
*
run*;
*;
/* open Excel workbook */
/*"N:\PM\PM_RF\CSVs\definitionT.csv" */
*;
filename ddecmd dde 'excel|system';
*
data* _null_;
file ddecmd;
put "[FILE-OPEN(""&dir.\CSVs\codemap.xls"")]";
*
run*;
*;
/* specify desired Excel worksheet cell range */
*;
filename xlin DDE "excel|&dir.\CSVs\[codemap.xls]codemap!r2c1:r3000c4";
*
run*;
*;
/* read Excel files using DDE into SAS data set*/
*;
*
data* user.codesetmaps_all;
infile xlin dlm='09'x notab missover dsd;
informat id *8.* codesetvalue $20. codeid *8.* codetypecd *8.*;
input id codesetvalue codeid codetypecd;
format id *8.* codesetvalue $20. codeid *8.* codetypecd *8.* ;
*
run*;
*;
/* close Excel workbook and close Excel */
*
data* _null_;
file ddecmd;
put "[FILE-CLOSE(""&dir.\CSVs\codemap.xls"")]";
put '[QUIT()]';
*
run*;
/*For program test and debug*/
*
data* user.rfs_labels (where=(id in (&testids.))); *(where=(id^=.));*;
set user.rfs_labels_all;
*
run*;
*
data* user.codesetmaps (where=(id in (&testids.)));* (where=(id^=.));*;
set user.codesetmaps_all;
*
run*;
/*
proc import out=user.ClaimHitsDriver
datafile = "N:\HI_Analytics\Projects\NCQA_DM_Test\NCQA
Codes\HEDISHitsDriver.txt"
dbms=tab replace; getnames=yes;
run;
proc sql;
create table work.HitsDriver as
select distinct CodeTypeCd, ColumnName1, ColumnName2, ColumnName3
from user.ClaimHitsDriver;
quit;
*/
*
%macro* createdsns(id);
data work.&client._var_&id;
length Elig_id $*30*;
length rf_&id *8*;
output;
run;
*
%mend*;
*
proc* *datasets* lib=work kill;
*
run*;
/* move relative files from warehouse sever to work;
data work.&client._claims;
set extn.&client._&SvcMths._MTH_&period._CLAIM;
run;
data work.&client._elig;
set extn.&client._&SvcMths._MTH_&period._elig;
run;
data work.&client._pharm;
set extn.&client._&SvcMths._MTH_&period._pharm;
run;
*/
* move relative files from warehouse sever to work;
*
data* work.&client._claims (rename=(elig_id=claim_elig_id));
set orig.&client._CLAIMS;
*
run*;
*
data* work.&client._elig;
set orig.&client._elig;
*
run*;
*
data* work.&client._pharm (rename=(elig_id=pharm_elig_id));
set orig.&client._pharm;
*
run*;
*Get eligible meidcal claim;
*
proc* *sql* noprint;
create table work.claims as
select distinct cl.*
from work.&client._claims cl, work.&client._elig e
where cl.claim_elig_id=e.elig_id;
*
quit*;
*Get eligible pharm claims;
*
proc* *sql* noprint;
create table work.pharm as
select distinct ph.*
from work.&client._pharm ph, work.&client._elig e
where ph.pharm_elig_id=e.elig_id;
*
quit*;
* all elig member;
*
data* work.elig;
set work.&client._elig;
*
run*;
*Get all involved reps;
*
proc* *sql* noprint;
create table work.&client._RF as
select distinct elig_id
from work.abb_elig
quit;
*
proc* *sort* data=work.&client._RF;
by elig_id;
*
run*;
/*
proc sql noprint;
create table work.&client._RFall as
select distinct elig_id label="Elig_id"
from
(
select distinct elig_id
from orig.&client._elig
) as a;
quit;
*/
/* create dummy datasets*/
*
data* _null_;
set user.rfs_labels;
call execute('%createdsns('||strip(id)||');');
*
run*;
*
proc* *sql* noprint;
select count(*) into: numRF
from user.rfs_labels;
*
quit*;
/*Make a label stirng*/
/* Set up column of result table;
proc sql
proc sql noprint;
alter table work.&client._RF
add rf1 int;
quit;
*/
* trasform codeset maps;
*
proc* *sort* data=user.codesetmaps out=work.codesetmaps;
by id codetypecd;
*
run*;
*
Data* work.codesetmaps_mac_loookup (drop=codesetvalue) ;
Length ValueString $ *2000* ;
Set work.codesetmaps ;
By ID CodeTypeCD ;
Retain ValueString ;
ValueString = CatX( ',' , ValueString ,cats("'",CodeSetValue,"'")); ;
If Last.CodeTypeCD Then Do ;
Output ;
Call Missing( ValueString ) ;
End ;
*
run*;
/* Get a specific target dataset
data work.target;
set work.codesetmaps_mac_loookup;
where id=1;
run;*/
*
%Macro* calculateRFs(codetypecd, id, valueString);
%if &CodeTypeCd = *2* %then %do;
proc sql noprint;
select lowcase(strip(type)) into:idtype
from user.rfs_labels
where id=&id;
quit;
%if &idtype=binary %then %do;
proc sql noprint;
create table work.temp&id as
select distinct claim_elig_id as elig_id,
*1* as RF_&id
from work.claims
where claim_icd1_code in(&valueString) or
claim_icd2_code in(&valueString) or
claim_icd3_code in(&valueString);
quit;
%end;
%else %do;
proc sql noprint;
create table work.temp&id as
select claim_elig_id as elig_id,count(*) as RF_&id
from work.claims
where claim_icd1_code in(&valueString) or
claim_icd2_code in(&valueString) or
claim_icd3_code in(&valueString)
group by claim_elig_id;
quit;
%end;
%end;
%else %if &codetypecd=*3* %then %do;
proc sql noprint;
select lowcase(strip(type)) into:idtype
from user.rfs_labels
where id=&id;
quit;
%if &idtype=binary %then %do;
proc sql noprint;
create table work.temp&id as
select distinct pharm_elig_id as elig_id,
*1* as RF_&id
from work.pharm p
where p.pharm_ndc_code in
(
select ndc_code from sqlref.ref_ndc_mast
where ndc_thera_class_code in (&valueString)
);
quit;
%end;
%end;
proc append base=work.&client._var_&id data=work.temp&id;
run;
*
%mend*;
*
data* _null_;
set work.codesetmaps_mac_loookup;
/*call execute ('%calculateRFs('||codetypecd||','||id||',' ||
'%nrstr('||trim(valueString)|| '));');*/
call execute ('%nrstr(%calculateRFs('||codetypecd||','||id||', %nrstr('||
trim(valueString)|| ')));');
*
run*;
/* Marco for sorting*/
*
%Macro* sortalldsn();
%do i=*1* %to *415*;
%if %sysfunc(exist(&client._rf_&i)) %then %do;
proc sort data=&client._rf_&i;
by id;
run;
%end;
%end;
*
%mend*;
option mprint mlogic symbolgen;
%*sortalldsn*();
*proc* *print* data=sashelp.class;
*
run*;
*
proc* *sql* noprint;
select cats("&client._var_",id) into: allids SEPARATED BY ' '
from work.codesetmaps_mac_loookup;
*
run*;
*
data* &client._all_rfs;
merge &client._rf &allids;
by elig_id;
*
run*;
*
proc* *print* data=abb_rf;
*
run*;
4.Clearing work.GSEG window when working with GPLOT interactive
Dear SAS-L,
Does anyone know how to clear the work.GSEG window of plots from consecutive
plots (work.gseg.glpot[1..n]) when working with
SAS and running glpot interactively.
Thanks, any help is appreciated.
Jake
5.OT: Working the program or letting it work you
In program a programmer has two choices: 1.) work the program and
supporting documentation so that it works for you or 2,) let the program
work the programmer, thus decreasing the programmer and programs value
to the company. Why is so hard for some people to admit that the system
they have been using for years just doesn't make the grade in world with
an ever increasing work load.
As I see it a company three choices when needing to increase efficiency,
first they can get better equipment and or software, secondly they could
increase the staff to do the work, and thirdly they can use what they
have more efficiently (avoided the whole off shore thing on purpose).
The current business climate of lowering costs and lower operating
budgets dramatically affects the first two and in some cases to the
point that they become unviable choices. This leaves us with the last
choice as the best and probably the choice that should have been
selected regardless of the budget in the first place. Unfortunately, I
have found that many programmers/management don't like change even when
it could save mountains of money or at the very least make their lives
easier through time saving efficiencies. They simply do not get the
concept of working a program instead they are unhappy over worked people
who grumble a lot about having to work long hours, the work load
increasing but their paychecks, and the lack staff.
Is it that hard to think before you act (program). By redesigning a
program so that the data flow is better, better program documentation,
comments, naming scheme, deciding what should be hard coded versus
dynamic more time is saved in the long run by faster programs that are
easier to maintain, easier to read, and well documented so your out of
program documentation is actually less than it was before. You know the
little things that when added up make a huge difference.
That's what I think I could be wrong.
Toby Dunn
Thanks for letting me rave on like a mad man.
6. %eval(2*3*4) work but %eval (V[i]) not work?
7. %eval(2*3*4) work but %eval (V[i]) not work?
8. What is thenature of this error: ERROR: You cannot open WORK._CONVERTDATA.DATA for output access with member-level control because WORK._CONVERTDATA.DATA is in use by