
Online
ballardw
Super User
Member since
06-23-2011
- 30,688 Posts
- 2,257 Likes Given
- 3,419 Solutions
- 12,225 Likes Received
-
Latest posts by ballardw
Subject Views Posted 34 3 hours ago 24 3 hours ago 119 yesterday 94 Wednesday 74 Wednesday 172 Wednesday 180 Tuesday 234 Tuesday 87 Monday 247 Saturday -
Activity Feed for ballardw
- Got a Like for Re: Help with macro error. 3 hours ago
- Posted Re: Help with macro error on SAS Programming. 3 hours ago
- Posted Re: The data cannot be imported on New SAS User. 3 hours ago
- Got a Like for Re: Arrays and do loop with different type of data. yesterday
- Posted Re: Arrays and do loop with different type of data on SAS Programming. yesterday
- Posted Re: Proc SQL into (MACRO) on SAS Programming. Wednesday
- Posted Re: Proc Freq Output Style on Statistical Procedures. Wednesday
- Posted Re: First page is blank when using page break, define option PAGE, and LINE command in compute block on SAS Programming. Wednesday
- Posted Re: Issue with Random Indentation Changes on SAS Programming. Tuesday
- Posted Re: Coloring sgplot lines by indicator variable value on Graphics Programming. Tuesday
- Posted Re: Distinct Calculation on SAS Viya. Monday
- Posted Re: How to import all excel files from a folder also create a new variable to store the file number on SAS Programming. Saturday
- Got a Like for Re: Can I add linebreaks to the select into :macro_vars?. a week ago
- Posted Re: Import an excel data with libname and change the column-variablename on SAS Programming. a week ago
- Posted Re: font for proc sgplot on ODS and Base Reporting. a week ago
- Got a Like for Re: I need help using sas with unix commands. a week ago
- Posted Re: I need help using sas with unix commands on SAS Enterprise Guide. a week ago
- Posted Re: Can I add linebreaks to the select into :macro_vars? on SAS Programming. a week ago
- Posted Re: Customize specific tick values, values order and add space between different hbars groups on Graphics Programming. a week ago
- Posted Re: PROC SQL to find nonmatches on Programming 1 and 2. a week ago
-
Posts I Liked
Subject Likes Author Latest Post 4 4 2 2 3 -
My Liked Posts
Subject Likes Posted 1 3 hours ago 1 yesterday 2 a week ago 1 a week ago 2 a week ago -
My Library Contributions
Subject Likes Author Latest Post 101 0 0 0 0
3 hours ago
1 Like
Please, please, PLEASE paste log and code entries as text in text boxes opened on the forum with the </> icon that appears above the main message windows.
It is quite often much easier to COPY - Edit - Paste suggested fixes to code. The more stuff that requires typing from scratch the less likely you are to get complete working code.
When debugging MACRO generated code then set OPTIONS MPRINT; before running the macro.
In this case, you have placed the value of the Type variable in the WHERE statement inside single quotes. Macro variables inside single quotes do not resolve at all. You must use double quotes
where type = "&type";
... View more
3 hours ago
First, is the XLS file where the EG server can see the file? I can't tell from the image is the XLS is local to your machine or on the server.
Also, XLS and XLSX files require additional licenses for Access to PC Files to Import to work.
You can see if you have the license by running:
Proc Setinit;
run;
Your log would show your license information including something that looks similar to:
---Base SAS Software
30JAN2060
---SAS/STAT
30JAN2060
---SAS/GRAPH
30JAN2060
---SAS/Secure 168-bit
30JAN2060
---SAS/Secure Windows
30JAN2060
---SAS Enterprise Guide
30JAN2060
---SAS/ACCESS Interface to PC Files
30MAY2062
---SAS/ACCESS Interface to ODBC
30MAY2062
If your log does not include the PC Files then you aren't licensed. If it does show the PC Files then run this code to see if it was installed:
Proc Product_status;
run;
Which would show something similar to:
For Base SAS Software ...
Custom version information: 9.4_M4
Image version information: 9.04.01M4P110916
For SAS/STAT ...
Custom version information: 14.2
For SAS/GRAPH ...
Custom version information: 9.4_M4
For High Performance Suite ...
Custom version information: 2.2_M5
For SAS/ACCESS Interface to PC Files ...
Custom version information: 9.4_M4
For SAS/ACCESS Interface to ODBC ...
Custom version information: 9.4_M4
If the PC Files does not appear in this output but does for the Proc Setinit then your need to re-install SAS, or have the admin that manages the SAS session you connect to with Enterprise Guide, to re-install SAS with PC Files.
Without the PC Files install you can use your spreadsheet software to save the file a CSV format file and import that newly saved CSV file. SAS will create a data step program that you can save to document the properties or to make changes for when the IMPORT procedure makes the wrong guess for the variable type such as creating numeric variables for things like Account numbers which loses information like leading zeroes.
There is an advantage to saving XLS or XLSX files to CSV if you have multiple files of the same structure that the same program can be used just change the input file name and the output data set. Otherwise multiple Imports may result in different variable types and lengths of variables that cause other problems later when combining similar data sets.
... View more
yesterday
1 Like
You log will show more than a single message:
10 data want;
11 set have;
12 array score {3} score1 - score3;
13 array grade {3} grade1 - grade3;
14
15 do i = 1 to 3;
16 if score(i) <= 25 then grade(i) = 'D';
17 else if score(i) <= 50 then grade(i) = 'C';
18 else if score(i) <= 75 then grade(i) = 'B';
19 else if score(i) <= 100 then grade(i) = 'A';
20 else grade(i) = "-";
21 end;
22 drop i;
23
24 run;
NOTE: Character values have been converted to numeric
values at the places given by: (Line):(Column).
16:10 16:30 17:13 17:33 18:13 18:33 19:13 19:36
20:10
NOTE: Invalid numeric data, 'D' , at line 16 column 41.
NOTE: Invalid numeric data, 'C' , at line 17 column 44.
NOTE: Invalid numeric data, 'B' , at line 18 column 44.
id=1 score1=25 score2=50 score3=75 grade1=. grade2=. grade3=. i=4 _ERROR_=1
_N_=1
NOTE: Invalid numeric data, 'A' , at line 19 column 47.
NOTE: Invalid numeric data, 'A' , at line 19 column 47.
NOTE: Invalid numeric data, 'A' , at line 19 column 47.
id=2 score1=100 score2=90 score3=80 grade1=. grade2=. grade3=. i=4
_ERROR_=1 _N_=2
NOTE: Invalid numeric data, 'D' , at line 16 column 41.
NOTE: Invalid numeric data, 'C' , at line 17 column 44.
NOTE: Invalid numeric data, 'B' , at line 18 column 44.
id=3 score1=17 score2=33 score3=72 grade1=. grade2=. grade3=. i=4 _ERROR_=1
_N_=3
NOTE: Invalid numeric data, 'B' , at line 18 column 44.
NOTE: Invalid numeric data, 'C' , at line 17 column 44.
NOTE: Invalid numeric data, 'A' , at line 19 column 47.
id=4 score1=55 score2=43 score3=95 grade1=. grade2=. grade3=. i=4 _ERROR_=1
_N_=4
NOTE: Invalid numeric data, 'A' , at line 19 column 47.
NOTE: Invalid numeric data, 'A' , at line 19 column 47.
NOTE: Invalid numeric data, 'C' , at line 17 column 44.
id=5 score1=76 score2=85 score3=39 grade1=. grade2=. grade3=. i=4 _ERROR_=1
_N_=5
NOTE: There were 5 observations read from the data set WORK.HAVE.
NOTE: The data set WORK.WANT has 5 observations and 7 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
The way you defined the Grade array creates numeric variables. So you cannot assign any of 'A', 'B' or other character value to them. If the variables do not have a predefined type then the Array statement creates numeric variables.
You can create character variables and avoid the invalid data message with:
array grade {3} $ grade1 - grade3 ;
which will create length 8 character variables. The $ as the first item after the array size indicates that you want character variables. If want a length other than 8, such as 1 to hold a single letter, specify the number of characters after the $.
array grade {3} $ 1 grade1 - grade3 ;
You probably still have a problem if I understand what your code is supposed to do as the missing values for the scores will all end up with letter D. That is because missing is less than 25. Missing is treated as less than any given value. So the first "IF" needs to address the missing. Note that you can test the missing value code by placing a dot in the position of one of the scores in the Have data step.
While the automatic conversions that SAS does can be helpful, you really should address the values so the message about the conversion doesn't appear. To numeric is often not a problem but other characters than digit and decimal may cause other errors. Is there some reason that the Scores are supposed to be character? As a minimum they won't sort well if you have values like 1 to 9 in the data.
... View more
Wednesday
Or place an actual character between values. If you see multiples of the character with no readable text between the values then you have missing values for the variable.
... View more
Wednesday
What is the purpose of having Surveyfreq and Freq output appear similar?
And by "output style" are you referring to the appearance in the result window only? The ODS OUTPUT creating a data set in Surveyfreq and either the OUT=option in Proc Freq or the ODS output to create data sets may be easier to similar output structures and then use a report procedure such as Print, Tabulate or Report to create desired human readable output.
... View more
Wednesday
@RooRoo wrote:
Thanks for your effort!
But there's still some issues.
First, the line 'End of Table' is seen on the two last pages instead of only the last one.
Besides, for groups with few entries thewe will be pages with too much empty space, whereas groups with too many entries would cause other problems. This why controlled page breaks are important here.
Hint: when trying to create an exact appearance then provide an example of what the desired appearance actually is, as in a manually created document. That way we can tell if the result of a code suggestion does not actually meet requirement. Without a clear requirement you will get many "close but not quite" because we don't know the actual requirement.
... View more
Tuesday
@bizbaz20 wrote:
Hi everyone,
I'm experiencing an issue with indentation in SAS Enhanced Editor. I manually indent my code using spaces instead of tabs, but whenever I reopen a SAS program, random extra spaces are added to my code. The number of added spaces is inconsistent—some lines get one extra space, while others get six or seven. When I delete these (using backspace or delete keys), sometimes it will delete the entire space in one go, but not always.
The highlighted text above indicates that TAB characters are in the file.
Note that the SAS auto indent will use tabs (which your editor settings can be made to save as spaces) even if you typically use the space key.
And if multiple people are editing the files then different settings of the editors for number of spaces a tab represents might come into play.
... View more
Tuesday
The plot GROUP= option uses one variable and generally creates one set of characteristics, color, marker, line type, pattern fill, depending on the values of the group variable and the type of plot.
ONE variable.
If you have multiple "group" variables you might be able to accomplish what you want with multiple PLOT statements. You can have more than one Series or Vline or what have in a single call to SGPLOT/SGPANEL . However the data organization may get messy. Same x,y value pair with different group variables will overlay each other and depending on settings like TRANSPARENCY may mean only the top most value is visible or hard to interpret.
Or create a single variable for the actual to plot group variable.
... View more
Monday
What is a "ref number"? I don't see anything in what looks like example data that is called "ref number". So as a very minimum you need to describe how we are to recognize a "ref number" and then describe how we are to tell what the "first entry per Ref number" might be.
Very likely this will involve two steps. First adding a calculated value that indicates it is the "first entry per Ref number". Then use that calculated variable to be part of a grouping.
... View more
Saturday
Warning: The SAS Import engine will make guesses for each file imported as to variable name, type and length. Which with as many files as you have typically means that some of the variables are of different types even from the same column that should be the same type as you perceive the file and the multiple lengths means that combining data sets later may lead to lose of data because of the rules involved when doing such.
IF these files are supposed to be of the same structure it may be worth the effort to save all of the files as CSV (yes 1000 files may take awhile) and write a data step to the resulting files (or import a few of those and edit the generated SAS code) to read such and set the properties you expect for each column. The INFILE statement used with a data step but not in IMPORT will also allow creating a variable using the FILENAME= that you can parse from the file name to add a variable, which I am assuming is meant by "Excel file number".
@gsreddy wrote:
Actually i have 1000 excel files in a folder. How to import all excel files from a folder and add all records into data, Also create a new variable in same data set to store the excel file number.
... View more
a week ago
An option that @Tom missed would be make sure that when using Proc Import that you use
options validvarname=V7;
The V7 refers to SAS version 7 where the longer variable names were acceptable. That option will turn all non-letter and non-digit characters into underscore and reduce the complexity of the rename code removing the need for the NLITERAL bits, as @PaigeMiller's example shows.
Perhaps a more important question, at least in my line of work, is why each of these sheets has a different set of column names at all if this is all related to a single project.
... View more
a week ago
You do not say where the font is not displaying correctly. Since your YAXIS statement spells the font differently I would not expect it to.
On my system using "Times New Roman" does work for the Axis statements using a different data set. I can't test your INSET as I am too lazy to completely fake such and you did not provide example data for the plot.
My code which uses a SAS supplied data set you should have to test the code. Since my values are different I do not attempt to use your values and used a different label so it is obvious that this is not your data.
Proc sgplot data=sashelp.class noborder ;
scatter x= height y= weight/jitter jitterwidth=0.2 markerattrs=(size=5);
xaxis label= "Student Height" labelattrs=(weight=bold size=14 family="Times New Roman" color=red);
yaxis label= "Student Weight" labelattrs=(weight=bold size=11 family="Times New Roman");
;
run;
Depending on your system the font names might differ in details of the name used.
@Judy518 wrote:
Hi there,
I was using proc sgplot to make a scatter plot and wanted the fonts for both label and legend be Times New Roman, but it didn't work for the following code. All the other options of labelattrs such as weight, size, color worked. Any ideas about this?
ods graphics/reset imagename="AF" imagefmt=png; Proc sgplot data=Model noborder ; scatter x= AC y= FR/jitter jitterwidth=0.2 markerattrs=(size=5); xaxis values=(0 to 7 by 1) label= " Rating by Rater1" labelattrs=(weight=bold size=14 family="Times New Roman" color=red); yaxis values=(0 to 7 by 1) label= "Rating by Rater2" labelattrs=(weight=bold size=11 family="Times_New_Roman"); inset " P value < 0.0001"/position=top textattrs=(size=12 weight=bold family="Times New Roman" color=red) noborder ; run;
Thanks!
... View more
a week ago
1 Like
If you can't access the files from the LINUX/ UNIX/ any operating system command line why should the user be able to circumvent the system security features such as permissions to do things in SAS?!?
I think the system administrator would be very cross with all involved.
If a user needs access then talk the admin about changing permissions.
... View more
a week ago
2 Likes
Why does the "want" for Horsepower show a line break after "text"? That's going to be a serious difference of logic if intentional.
Where do you expect this to display? Is this only for the log or elsewhere? I'm not sure that the unicode characters display well in the LOG.
Any particular reason you didn't use the NEWLINE function instead of the unicode character? Not that the LOG likes that any better in a macro variable.
Here's an example, that depending on your settings may display something similar to what you want in the results window using FILE PRINT with PUT. Remove the File Print and see what the LOG shows for why I commented about unicode and inline formatting.
Then a Proc Print of a variable built.
data junk (keep=lngstr);
set namy (where= (name in ("Cylinders" "DriveTrain"))) end=lastone ;
length lngstr $5000 ;
retain lngstr;
lngstr = catx(",(*ESC*){newline}",strip(lngstr),
catx(' ', '{name=',quote(strip(name)), "label=", quote(strip("&abc")), '}'));
file print;
if lastone then do;
put lngstr;
call symputx('oks2',strip(lngstr));
output;
end;
run;
%put %bquote(&oks2.);
proc print data=junk noobs;
var lngstr;
run;
... View more
a week ago
Please re-post the code for creating your example data in a text box. Open the text box by clicking on the </> icon and paste the code. The main message window reformats pasted code and so the there is no space between the end of the Region values and so we get "Region" values that look like "Asia -1.53 20" because of reading 13 characters. Also several of the lines end up to short and get the log note
NOTE: SAS went to a new line when INPUT statement reached past the end of
a line.
Which usually indicates a read problem.
... View more