- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello I use SAS EG and I'm wondering if there is a way to compress this kind of code, so I don't have to write 100 rows. If Columns 1 to 100 are together in the data, then if you wanted to keep those columns you could do keep Column1--Column100, is there something similar you could do here?
if Column1 = X and
Column2 = X and
...
Coloumn100 = X
then do Y
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Checking for clarification ... do you want to find one (or more) of COLUMN1-COLUMN100 which has the value 'X', or do ALL columns have to have value 'X'???
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I'm curious about either. Also I would like to know how to check if many columns are missing or not missing, both for character and numeric. I know this is a lot, but the case I'm most interested in at the moment is checking something like this, for numeric variables, where if at least one field is not missing, then do X
if not(
Column1 = .
and Column2 = .
...
and Column100 = .)
then do X
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Find if all columns are the value 'X'
string=(cat(of column1-column100));
if findc(trim(string),'X','k')=0 then ...
Find if one (or more) of the columns have the value 'X'
if whichc('X',of column1-column100)>0 then ...
If the variables are numeric, then you would use the WHICHN function.
The columns do not have to be together, but all 100 must be exist.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks! Do you know how to check if they are missing or not missing, instead of being equal to value X?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use '.' instead of 'X' in FINDC
Use . instead of 'X' in WHICHN
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks! One more question, if I have a long list of columns that are not numbered, but are together in the data, is there a way to use the "--" functionality somehow? For example I would like to compress the following code, where the columns BI through Roof are together in the data:
proc sql;
select distinct Variable into: varlist separated by ' ' from factor.vehfactor_RAD7MM
where CustomerGroup in ('ABM','AFF','RV')
and Variable not in ('SymbolLiab','SymbolPhy','AgeSymDed','VehHisCodeNew','IRM'
,'NewBusDisc','SRMCode_v41','SR_Group', 'TerritoryNew'
)
and not (BI = . and
PD = . and
MED = . and
UMBI = . and
UMPD = . and
COMP = . and
COLL = . and
PERS = . and
FTBI = . and
RENT = . and
TOW = . and
CUST = . and
AAE = . and
ADD = . and
DimDed = . and
RVVL = . and
RVMX = . and
PPMX = . and
RVEE = . and
RVConsign = . and
Pest = . and
Roof = .
)
;
quit;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Please give it a try and see what happens.
Paige Miller