Hello everyone,
I am trying to create a dynamic proc format that is based on the monthly data for the past 7 or 8 years. I am using SAS version SAS 9.4 and enterprise guide 8.3. Here is a look at a portion of the normal proc format that I am trying to emulate.
proc format; INVALUE classordinal '2016-05'= 1 '2016-06'= 2 '2016-07'= 3 '2016-08'= 4 '2016-09'= 5 '2016-10'= 6 '2016-11'= 7 '2016-12'= 8 '2017-01'= 9 '2017-02'= 10 '2017-03'= 11 '2017-04'= 12
;
RUN;
I figured out how to generate the needed months, but don't know how to put it into a proc format statement.
data empty; format vintage yymmd7.; do i = 96 by -1 to 1; vintage = intnx('month', today(), -i, 'B'); classrank = 97 - i; output; end; drop i; run;
proc sql; select put(vintage, yymmd7.), put(classrank, 8.) into :vintages separated by ' ', :classranks separated by ' ' from empty; quit;
results
2016-05
1
2016-06
2
2016-07
3
2016-08
4
2016-09
5
2016-10
6
2016-11
7
2016-12
8
2017-01
9
2017-02
10
2017-03
11
2017-04
12
Thanks for your help.
... View more
I am configuring Oracle on new 9.4 M8 and below are the entries I made in sasenv_local after having Oracle configured on Linux. everything looks good as per SAS documentation but still getting the error. Can you please suggest where things are going wrong?
Note : I have restarted Connect and Share services after updating sasenv_lcoal.
libname mydblib oracle user=uname password=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ! path=<mypath from tnsnames.ora>; ERROR: Unable to load oracle client (libclntsh.so) ERROR: Error in the LIBNAME statement.
sasenv_local entries:
ODBCHOME=/sas/sashome/AccessClients/9.4/SQLServer export ODBCHOME
ORACLE_HOME=/sas/oracle/product/12.2.0/dbhome_1 export ORACLE_BASE=/sas/oracle export PATH=$ORACLE_HOME/lib:$PATH LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH export LD_LIBRARY_PATH
echo $PATH /sas/sashome/SASFoundation/9.4:/sas/oracle/product/12.2.0/dbhome_1/lib:/sas/sashome/SASFoundation/9.4:/sas/oracle/product/12.2.0/dbhome_1/bin:/home/sas/.local/bin:/home/sas/bin:/usr/share/centrifydc/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sas/config/Lev1/Applications/SASGridManagerClientUtility/9.4/
echo $LD_LIBRARY_PATH /sas/sashome/AccessClients/9.4/SQLServer/lib:/sas/oracle/product/12.2.0/dbhome_1/lib
... View more
Hi, tsmk is my time-dependent covariate, deathstatus_inhance is censor, and stime_inhance is time. The "Change step" worked well, but the "Count step" only worked for four observations and stopped. Please help me to correct my code. DATA analysis.change;
SET analysis.smk_stime2;
ARRAY tsmk_(*) tsmk_1-tsmk_5; *call in the time-varying smoking variables;
ARRAY chng(5); *the new indicator variables;
t=1; *initialize the position variable for the indicator variables;
DO i = 2 TO 5;
IF tsmk_(i) NE tsmk_(i-1) THEN DO; *detects whether there is a change in smoking status;
chng(t) = i-1; *assigns the last year the status remained constant;
t=t+1;
END;
END;
RUN;
DATA analysis.count;
SET analysis.change;
ARRAY tsmk_(*) tsmk_1-tsmk_5; /* call in the time-varying smoking variables */
ARRAY chng(*) chng1-chng5; /* call in the indicator variables */
start = 0; /* initialize the beginning time for the study */
censor2 = 0; /* initialize the new censor variable */
t = 1; /* initialize the position variable for the indicator variables (chng1-chng5) */
DO i=1 TO stime_inhance; /* makes sure we only output the records that smoking status remains constant */
IF (chng(t) > . and chng(t) < stime_inhance) or i = stime_inhance THEN do;
/* assign the value of smoking status */
IF chng(t) > . THEN smoking_status = tsmk_(chng(t));
ELSE smoking_status = tsmk_(stime_inhance); /* assign the end time */
stop = min(chng(t), stime_inhance); /* assign the value of the censor variable */
IF i = stime_inhance THEN censor2 = deathstatus_inhance; /* assign the new start time */
IF t > 1 THEN start = chng(t-1); /* move the position variable */
t = t + 1;
OUTPUT; /* output the record to the new dataset */
end;
END;
RUN;
... View more
Hello everyone, I am new to statistical programming for a multilevel/mixed modeling. I am conducting a study where the outcome is (YES/NO) binary indicating the provision of HIV treatment at the facility level. My primary independent variable is the facility payment type i.e. accepts private, public insurance or cash payment; covariates include the census region, state policy on HIV programs, and state HIV prevalence rate. I am conducting logistic regression analysis as follows: Provision of HIV treatment= B0 +B1 (payment type) + B2 (census region) + B3 (state HIV policy) + B4 ( tertile of state HIV prevalence rate) My goal is to assess the association between payment type and provision of HIV treatment. My question is that the unit of analysis for this study is the FACILITY whereas the information for state HIV policy and prevalence rate is pulled from the state level data and then extended to facility level depending on which state the facility belongs to. For eg: If California has highest HIV prevalance rate, according to the tertile category, it falls in the highest tertile group with value 2; because the tertile has values 0,1,2. Now because California has the value of prevalence rate=2, all the facilities belonging to the state of California has value of 2 assigned to them for the purpose of the analysis. Similarly facilities belonging to other states have been assigned values depending on which category the state is assigned. I am not sure which is the correct model to use here? does simple proc logistic will do and if the methodology of extending state level information to facility level is correct because there might be states with a large number of facilities or vice versa? Your help is appreciated!
... View more
From Zero to SAS: Using SAS Studio to Summarize and Manipulate Your Data Q&A, Slides, and On-Demand Recording
Watch this Ask the Expert session to learn how to point and click your way to summarizing and manipulating data with SAS Studio before analysis.
Watch the webinar
You will learn about:
The features of various versions of SAS Studio.
Using Tasks and Steps in SAS Studio to manipulate and summarise data.
The questions from the Q&A segment held at the end of the webinar are listed below and the slides from the webinar are attached.
Q&A
Answered
Where does SAS Enterprise 8.3 belong?
Enterprise Guide 8.3 is a different application than SAS Studio. Although, it can also be used to write and develop SAS code and use point-and-click functionality to generate code. Enterprise Guide is a Windows application, while SAS Studio is browser-based.
Can you save an autoexecute file in SAS Studio on SAS 9?
Yes, there is the ability to create and save an autoexec file in all versions of SAS Studio. In SAS Studio on SAS 9, it's under the More Application Options menu in the upper right corner.
SAS Studio 3.8 - Editing the Autoexec File
In SAS Studio on SAS Viya, access the autoexec using the Options button on the Application menu.
You can add to that, or you can copy and paste it and put it into another SAS program.
SAS Studio 2024.x - Editing the Autoexec File
How do I get dark theme in SAS Studio?
There isn't currently an option to view in dark theme in SAS Studio 3.8.
For SAS Viya 2024.x
User icon (top right of the application bar) > Settings> General> Choose a theme drop-down menu.
What is the best browser to run SAS studio on SAS 9?
SAS Studio supports multiple web browsers, including Google Chrome, Apple Safari, and Mozilla Firefox. Some releases of SAS Studio also support Microsoft Internet Explorer and Microsoft Edge. I personally use Chrome. Here is a link to the documentation for more information: https://support.sas.com/software/products/sas-studio/faq/SASStudio_browsers.htm#:~:text=SAS%20Studio%20supports%20multiple%20web,Internet%20Explorer%20and%20Microsoft%20Edge.
Can you show how you linked them at the end again?
You can click on the output port (on the right side) of one node and drag to the input port (on the left side) of another node.
Did you say there is a free SAS Studio version online? If yes, how can I access it?
Yes! Here's the link to SAS On-Demand for Academics, which is free access to SAS Studio 3.8 on SAS 9. It is available for anyone learning SAS, whether you are an official student or not: https://www.sas.com/en_us/software/on-demand-for-academics.html If you want to try SAS Studio on SAS Viya, then here is a link to the 14-day free trial: https://www.sas.com/en_us/trials/software/viya/viya-trial-form.html
If you are a student with a university email you can access SAS Viya for Learners.
Here is the link for SAS® Viya for Learners
What is SAS Studio? What’s different from other SAS interfaces?
We have lots of different applications in SAS and they're all designed to do something slightly different. The applications used for writing and submitting SAS code are mainly Base SAS (also called the Windowing environment, or the Display Manager), SAS Studio, and SAS Enterprise Guide. But the application that's generally compared to SAS Studio is SAS Enterprise Guide. They both have the point-and-click interface and they both can write and submit code. The biggest difference between the two is the fact that you can use SAS Studio on a web browser, whereas SAS Enterprise Guide is a Microsoft Windows application. But they are generally quite similar.
You seem to have a lot more options in the SAS Steps section. Is it because I'm running another version of SAS Studio Analyst (2022.09)?
Yes, that's definitely the case. We have added a lot more steps since that version. And we continue to add more with each release.
This link takes you to the most up-to-date documentation on flow functionality, including the steps available. Use the version drop-down menu to select your version of the software.
Do you have a list of best practices when using SAS Studio Visual Programming?
Please see this SAS Communities post for more information on the Visual Programming perspective. SAS Studio 3.8 Visual Programming
Is it possible to import process flows from EG?
When you open a SAS Enterprise Guide project in SAS Studio 3.8, the process flows in the project are extracted and converted to process flows in SAS Studio. For more information here - Converting SAS Enterprise Guide Projects to SAS Studio Process Flows
For SAS Studio 2024.x, you would need to migrate the Enterprise Guide project. SAS Studio will endeavour to translate the tasks used in SAS Enterprise Guide into steps in SAS Studio. You want to make sure that SAS Studio has migrated the flow correctly. For more information Tips for SAS Enterprise Guide Users
Where is the SQL displayed and saved? And how many kinds of joins are in the dropdown list?
In SAS Studio 3.8
With the Code/Results view active in the Query task, select Edit to create a copy of the code in a new SAS program. Please note, the code is no longer connected to the task and vice versa.
There are 4 types of joins; inner, left, right and full join.
SAS Studio 2024.x
When using a Query step in a flow you can review/copy the generated code (as per picture below). This is for the whole flow.
When using a standalone query you can Edit the code, as per below screenshot.
There are currently 4 types of joins; inner, left, right and full join. Always check the most up-to-date documentation.
Can it handle large datasets with millions of records (>20 GB size)?
Yes, but performance always depends on the size of the SAS server provisioned behind the scenes.
Will the drag and drop join work, if the target columns from different tables are not named the same, or not formatted the same? For example, Country $20 vs. CTRY $2
Tables can be joined based on columns with different names. SAS automatically matches columns with the same name and type for the join. If no matches are found, a manual join can be performed.
Can it convert existing SAS code into a process flow?
Yes, you can convert existing SAS code into a flow in SAS Studio 2024.x. When the SAS program has been saved, either right-click on the .sas program using the Explorer section of the navigation pane and select Create flow from program or open the flow, click More Options (3 dots in the right of the program window) and select Create flow from program. Follow the instructions.
Do we have Chi-square testing functionality in the versions you demonstrated here?
Yes, you can achieve Chi-square testing functionality by using the One-Way Frequencies Task/Step.
SAS Studio 3.8 – One-Way Frequencies Task: Setting Options
SAS Studio 2024.x - One-Way Frequencies
I am a little confused as to the purpose of the City table in the process flow window. Can you explain?
The CityState column in the Employeesales SAS table contains the City and State. The demo extracted the state from the CityState column and created a new column called State, that only contained the last word (after the comma).
Do we have a similar webinar/training for SAS EG?
We do have lots of training for SAS Enterprise Guide.
https://learn.sas.com/enterprise_guide
Ask the Expert- SAS Enterprise Guide
Currently, we cannot connect to Unix and Local in EG, is that possible to do in Studio? Not sure if this is our enterprise limitation or not.
I would have to know a little bit more about what's going on in the set up. My advice would be to reach out to Technical Support and ask them to help if you're having any issues like that.
How do I export tables loaded in memory to local in SAS Viya?
You can use the PROC CASUTIL step with the SAVE statement to save an in-memory table to a variety of different file types (SASHDAT, SAS7BDAT, XLSX, CSV and others). Once the file is saved to disk, you can use the Explorer in SAS Studio to navigate to the file on your SAS Server, then right-click and select Download to download a copy to your local machine.
When you create flows by migrating multiple Data Integration Studio jobs, does it place the flow nodes? And does each node become its own node of code or is the migration tool smart enough to see the same node being used over and over and create just one reused node?
Please see Tips for SAS Data Integration Studio Users for information on migrating DI Studio jobs.
Recommended Resources
Many of the resources on this page are for SAS Studio 3.8
Whilst many resources on this page are for SAS Studio on SAS Viya (2024.x)
SAS Studio, SAS Studio Analyst & SAS Studio Engineer- oh my!
General Feature Comparison among SAS Studio Releases
What Is the Difference between SAS Studio Tasks and Custom Steps?
SAS OnDemand for Academics
Getting Started with SAS Studio - Youtube
Getting Started with SAS Studio - Tutorial
Overview of SAS Studio Tasks 5.2 (use the version drop-down menu to select your SAS studio version)
Understanding Tasks in SAS Studio 5.2 (use the version drop-down menu to select your SAS studio version)
Want more tips? Be sure to subscribe to the Ask the Expert board to receive follow up Q&A, slides and recordings from other SAS Ask the Expert webinars.
... View more