yesterday
Tom
Super User
Member since
07-09-2011
- 24,629 Posts
- 2,007 Likes Given
- 3,480 Solutions
- 12,753 Likes Received
-
Latest posts by Tom
Subject Views Posted 287 yesterday 380 yesterday 408 yesterday 135 Monday 84 Monday 201 Monday 581 Sunday 264 Saturday 285 Friday 288 Friday -
Activity Feed for Tom
- Got a Like for Re: Thoughts and questions: why this kind of macro is so difficult to debug.. yesterday
- Got a Like for Re: How to display the bars in alphabetical order?. yesterday
- Posted Re: How to display the bars in alphabetical order? on Graphics Programming. yesterday
- Posted Re: Da Access SQL a SaS on SAS Programming. yesterday
- Posted Re: Da Access SQL a SaS on SAS Programming. yesterday
- Got a Like for Re: csv import fails to open all records in file. yesterday
- Posted Re: csv import fails to open all records in file on SAS Programming. Monday
- Posted Re: Thoughts and questions: why this kind of macro is so difficult to debug. on SAS Programming. Monday
- Posted Re: Print the same SAS Log to BOTH the log window and external file at the same time on SAS Programming. Monday
- Posted Re: I AM NOT ABLE TO EXECUTE MERGE BETWEEN TWO DATA SETS. SAS IS NOT ABLE TO DETECT DATA SET A AND B on SAS Programming. Sunday
- Posted Re: Check non matching string dynamic datasets on SAS Programming. Saturday
- Posted Re: Return word number in a string on New SAS User. Friday
- Posted Re: Error---ODS EXCEL with now option on SAS Programming. Friday
- Liked Re: Error---ODS EXCEL with now option for SASKiwi. Friday
- Posted Re: proc report---export to excel--row height on SAS Programming. Friday
- Got a Like for Re: Thoughts and questions: why this kind of macro is so difficult to debug.. Friday
- Got a Like for Re: Thoughts and questions: why this kind of macro is so difficult to debug.. Friday
- Posted Re: Thoughts and questions: why this kind of macro is so difficult to debug. on SAS Programming. Friday
- Posted Re: export 2 table into sheet1 and 2 tables into sheet 2 in one XLSX file on SAS Programming. Friday
- Posted Re: export 2 table into sheet1 and 2 tables into sheet 2 in one XLSX file on SAS Programming. Friday
-
Posts I Liked
Subject Likes Author Latest Post 2 2 2 2 4 -
My Liked Posts
Subject Likes Posted 1 Monday 1 yesterday 1 Monday 1 Wednesday 1 Friday -
My Library Contributions
Subject Likes Author Latest Post 1 6 12 0 2
yesterday
1 Like
What type of variable is COUNTRY? Is it NUMERIC of CHRACTER? Does it have FORMAT attached to it?
... View more
yesterday
?? Is was just and example SQL query since you did show what the missing query was.
So
select a,b,c from x.y
Says to retrieve the variables A B and C from the dataset Y in the library pointed to by the libref X.
One thing you will definitely need to change from Microsoft syntax is the way you refer to names (tables or datasets, columns or variables, etc). You cannot use those square brackets in SAS code.
So something like giudizi_audit.[gia_val] in your example will need to be converted to normal syntax like giudizi_audit.gia_val .
... View more
yesterday
No idea what you mean by "RECALL".
If you want to replace a table reference like q_ultimi_ia_3 with a sub-query then just do that.
So if you had
... INNER JOIN q_ultimi_ia_3 ON ...
You could run something like
... INNER JOIN (select a,c,c from x.y) q_ultimi_ia_3 ON ...
... View more
Monday
1 Like
@sum_sand wrote:
Any way to find out why few records are failing to open with SAS.
Not sure what that means. If the file is being truncated that is usually caused by data step assuming it should stop when it sees the "DOS end of file" character. There is an IGNOREDOSEOF option you can add to the INFILE statement to stop that.
https://communities.sas.com/t5/SAS-Programming/importing-data-stops-SAS-in-the-middle-of-a-textfile-without/td-p/652791
But if your file has that character in it then you might have bigger issue since it is not something that would normally appear in a TEXT file, which CSV files are.
... View more
Monday
1 Like
A word of warning. Using COMMA as the delimiter in macro variables will make your code harder to write and maintain. That is because SAS uses comma already in a lot of places. For example as the delimiter between arguments to a function call or between parameter values in a macro call.
1 %macro x_in_y(x,y) / minoperator mindelimiter=',';
2 %if &x in &y %then %put &=x is in &=y;
3 %else %put &=x is NOT in &=y;
4 %mend x_in_y;
5
6 %x_in_y(AB,AB,CD);
ERROR: More positional parameters found than defined.
7
It is best to use some other character instead. Spaces are the easiest to type (and read) but might be impractical if the values in the list might contain spaces. In that case use some other character like | that will not appear in the items in the list.
8 %macro x_in_y(x,y) / minoperator mindelimiter='|';
9 %if &x in &y %then %put &=x is in &=y;
10 %else %put &=x is NOT in &=y;
11 %mend x_in_y;
12
13 %x_in_y(AB,AB|CD);
X=AB is in Y=AB|CD
Also your use of %INDEX() will risk false matches when the value entered forms part of one of the words in the list. It might be better to use %SYSFUNC() to call the SAS function INDEXW() or FINDW() instead to prevent matches on parts of a value. See the earlier post I did in this thread on that topic.
... View more
Monday
If you are changing the COMMAND you run there is no need to modify the CONFIG file since you can add the -altlog option to the COMMAND.
... View more
Sunday
You seem to have two different KEY variables. Which one is the important one? ID or NAME?
Merging by NAME leads to a different result
than merging by ID.
... View more
Saturday
If you want to compare the values of a variable (whether it is character or numeric) between two datasets a MERGE is a good method. Make sure the data is sorted by the variable.
data data_1apr2025;
input data :date. tkt $;
format data date9. ;
datalines;
01APR2025 3333123
01APR2025 43333111
;
data data_2apr2025;
input data :date. tkt $;
format data date9. ;
datalines;
02APR2025 11111111
02APR2025 43333111
02APR2025 99999999
;
Now you can merge and use the IN= dataset option to check if the values exists in both datasets or not.
data want;
merge data_1apr2025(in=in1) data_2apr2025(in=in2);
by tkt;
if not (in1 and in2);
run;
Results:
OBS data tkt
1 02APR2025 11111111
2 01APR2025 3333123
3 02APR2025 99999999
If you don't want that second mismatch for some reason then just change the criteria.
if in2 and not in1;
But since you also have the DATE (named DATA for some reason) in the dataset perhaps it would be easier to interleave the datasets instead? Then the check for a mismatch is just whether there is more than one observation. So the IN= dataset option is not needed.
data want;
set data_1apr2025 data_2apr2025;
by tkt data;
if (first.tkt and last.tkt);
run;
Or perhaps you want to find the places where there is a gap in the appearance of TKT for one or more dates?
data data_3apr2025;
input data :date. tkt $;
format data date9. ;
datalines;
03APR2025 3333123
03APR2025 43333111
;
data want;
set data_: ;
by tkt data;
lag_data=lag(data);
format lag_data date9.;
if (not first.tkt) and (data-1 ne lag(data));
run;
Result
OBS data tkt lag_data
1 03APR2025 3333123 01APR2025
... View more
Friday
Annoyingly, it also doesn't consider a word that ends with punctuation, like "word." to be a word either
That is what the delimiter parameter is for. Also consider the use of the I and T options. And the S option is useful with T to make sure that the space does to get removed from the delimiter list.
524 data example;
525 input string $50.;
526 word = 'word';
527 position = findw(string, word, '.?!,:;','site');
528 put position= string=;
529 datalines;
position=8 string=This is a sample string containing the word.
position=0 string=Another example without the keyword.
position=2 string=The word appears here.
... View more
Friday
Show the value of SYSVLONG, not _CLIENTVERSION.
It does not matter what version of Enterprise Guide you are using to edit your SAS code. Just like it would not matter what version of EMACS or VSCode you were using to edit your SAS code.
... View more
Friday
Looks to me your issue is with the column width, not the row height.
In your first picture the PCT*W column is wrapping into two lines, which is why it needed to make the row taller.
... View more
Friday
1 Like
If you want to use %INDEX() to search for WORDS instead of SUBSTRINGS then it helps to add the delimiter into both the search term and the valid value list. SInce you are using space as the delimiter use %STR() to add macro quoting so that the macro processor sees the leading/trailing spaces.
%if %index(%str( &ctrylist ),%str( &ctry )) %then %do;
This will prevent you from getting false positives for single letter values instead of the two letter codes you want to match.
1 %let CTRYLIST=AT AU BE CA CH CI ;
2 %let CTRY=AU;
3 %put &=ctry is located at byte %index(&ctrylist,&ctry);
CTRY=AU is located at byte 4
4 %put &=ctry is located at byte %index(%str( &ctrylist ),%str( &ctry ));
CTRY=AU is located at byte 4
5
6 %let CTRY=B;
7 %put &=ctry is located at byte %index(&ctrylist,&ctry);
CTRY=B is located at byte 7
8 %put &=ctry is located at byte %index(%str( &ctrylist ),%str( &ctry ));
CTRY=B is located at byte 0
... View more
Friday
@Ronein wrote: So what do you recommend me to do? I am using enterprise guide 8.3
For ODS EXCEL it does not matter what user interface you are using to connect to SAS, but the version of SAS that you are currently using to run the code. There is probably a button in EG you can click on that will show you information about the version of SAS you are currently using. Otherwise add this line to your code:
%put &=sysvlong;
The example code works fine on SAS 9.4m7 release.
1 %put &=sysvlong;
SYSVLONG=9.04.01M7P080520
2 ods excel file="c:\downloads\ABC12.xlsx"
3 options(sheet_name="Sh1" sheet_interval="none")
4 ;
5 title 'Table1';
6 proc print data=sashelp.class(obs=3) noobs;
NOTE: Writing HTML Body file: sashtml1.htm
7 run;
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.38 seconds
cpu time 0.03 seconds
8 title 'Table2';
9 proc print data=sashelp.shoes(obs=3) noobs;
10 run;
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
11
12 /*This tells SAS to start a new sheet for next PROCs*/
13 ods excel options(sheet_name="Sh2" sheet_interval="now");
14 proc print data=sashelp.cars(obs=5);
15 run;
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds
You might try just re-typing the line. Perhaps some strange hidden character got into your source code somehow.
Note that the error message I get when I purposely use a wrong value for SHEET_INTERVAL does include NOW as a valid option.
WARNING: Argument noow for word option sheet_interval not recognized. Expecting one of these keywords
output, table, page, bygroup, bygroups, proc, none, now or none.
21 ods excel options(sheet_name="Sh2" sheet_interval="noow");
... View more
Friday
What version of SAS are you using. SAS will display it at the top of the SAS log, but since you appear to be using something like SAS/Studio or Enterprise Guide to submit you SAS code finding the actual top of the SAS log might be difficult. So you can look at the value of the automatic macro variable SYSVLONG.
It really looks like a bug in SAS since the error message you show is confused, listing NONE twice.
ERROR: Argument now for word option sheet_interval not recognized. Expecting one of these keywords output, table, page, bygroup, bygroups, proc, none or none.
... View more
Thursday
I doubt if Enterprise Guide has any GUI tools to handle this, so just write normal SAS code instead.
If the white spaces are actual tabs just use the COMPBL() function to collapse the multiple adjacent spaces into one.
string=compbl(string);
If you also need to remove leading spaces use LEFT() function. Don't worry about trailing spaces, SAS variables are fixed length and padded with spaces, so any trailing spaces you remove will just reappear once you store the value back into a variable.
... View more