BookmarkSubscribeRSS Feed
adex0510
Calcite | Level 5

Task

Using the two datasets below (partial data shown), write SAS syntax that would answer the following question:  What proportion of close contacts were tested in the 5-10 day window of their quarantine period?  Include documentation throughout your code.  Comment on any assumptions you make or questions you would ask if you had the opportunity to iterate on this task.  Include syntax that would create output suitable to answer this question.

6 REPLIES 6
adex0510
Calcite | Level 5

Task

Using the two datasets below (partial data shown), write SAS syntax that would answer the following question:  What proportion of close contacts were tested in the 5-10 day window of their quarantine period?  Include documentation throughout your code.  Comment on any assumptions you make or questions you would ask if you had the opportunity to iterate on this task.  Include syntax that would create output suitable to answer this question.

Reeza
Super User
FYI - please do not post the same question multiple times. I've merged your posts. Just as a heads up for homework questions many users prefer you show an attempt to solve the problem yourself before providing any solutions.

Please show what you've tried so far and include specific question, right now this could very easily be interpreted as asking someone to do your homework for you since you've copy and pasted the questions from your assignment.
adex0510
Calcite | Level 5
Here is what i arrived at
/* Generated Code (IMPORT) */
/* Source File: RI Data Set.xlsx */
/* Source Path: /home/u58810830 */
/* Code generated on: 9/29/21, 3:18 PM */

%web_drop_table(WORK.IMPORT2);


FILENAME REFFILE '/home/u58810830/RI Data Set.xlsx';

PROC IMPORT DATAFILE=REFFILE
DBMS=XLSX
OUT=WORK.IMPORT2;
GETNAMES=YES;
RUN;

PROC CONTENTS DATA=WORK.IMPORT2; RUN;


%web_open_table(WORK.IMPORT2);


1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 /* Generated Code (IMPORT) */
70 /* Source File: RI Data Set.xlsx */
71 /* Source Path: /home/u58810830 */
72 /* Code generated on: 9/29/21, 3:18 PM */
73
74 %web_drop_table(WORK.IMPORT2);
NOTE: Table WORK.IMPORT2 has been dropped.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 192.31k
OS Memory 25504.00k
Timestamp 09/29/2021 08:27:47 PM
Step Count 98 Switch Count 2
Page Faults 0
Page Reclaims 15
Page Swaps 0
Voluntary Context Switches 10
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 0


75
76
77 FILENAME REFFILE '/home/u58810830/RI Data Set.xlsx';
78
79 PROC IMPORT DATAFILE=REFFILE
80 DBMS=XLSX
81 OUT=WORK.IMPORT2;
82 GETNAMES=YES;
83 RUN;

NOTE: One or more variables were converted because the data type is not supported by the V9 engine. For more details, run with
options MSGLEVEL=I.
NOTE: The import data set has 19 observations and 5 variables.
NOTE: WORK.IMPORT2 data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.00 seconds
user cpu time 0.00 seconds
system cpu time 0.01 seconds
memory 2765.00k
OS Memory 28068.00k
Timestamp 09/29/2021 08:27:47 PM
Step Count 99 Switch Count 2
Page Faults 0
Page Reclaims 659
Page Swaps 0
Voluntary Context Switches 17
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 264


84
85 PROC CONTENTS DATA=WORK.IMPORT2; RUN;

NOTE: PROCEDURE CONTENTS used (Total process time):
real time 0.03 seconds
user cpu time 0.04 seconds
system cpu time 0.00 seconds
memory 1716.87k
OS Memory 26536.00k
Timestamp 09/29/2021 08:27:47 PM
Step Count 100 Switch Count 0
Page Faults 0
Page Reclaims 122
Page Swaps 0
Voluntary Context Switches 0
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 16


86
87
88 %web_open_table(WORK.IMPORT2);
89
90 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
100

User: u58810830
Statement Options

The CONTENTS Procedure
Data Set Name WORK.IMPORT2 Observations 19
Member Type DATA Variables 5
Engine V9 Indexes 0
Created 09/29/2021 15:27:48 Observation Length 84
Last Modified 09/29/2021 15:27:48 Deleted Observations 0
Protection Compressed NO
Data Set Type Sorted NO
Label
Data Representation SOLARIS_X86_64, LINUX_X86_64, ALPHA_TRU64, LINUX_IA64
Encoding utf-8 Unicode (UTF-8)
Engine/Host Dependent Information
Data Set Page Size 131072
Number of Data Set Pages 1
First Data Page 1
Max Obs per Page 1557
Obs in First Data Page 19
Number of Data Set Repairs 0
Filename /saswork/SAS_work18D70001DC82_odaws02-usw2.oda.sas.com/SAS_workAF000001DC82_odaws02-usw2.oda.sas.com/import2.sas7bdat
Release Created 9.0401M6
Host Created Linux
Inode Number 536894750
Access Permission rw-r--r--
Owner Name u58810830
File Size 256KB
File Size (bytes) 262144
Alphabetic List of Variables and Attributes
# Variable Type Len Format Informat Label
2 B Char 24 $24. $24. B
3 C Char 14 $14. $14. C
1 Contacts Dataset: Char 16 $16. $16. Contacts Dataset:
4 D Char 14 $14. $14. D
5 E Char 16 $16. $16. E
Reeza
Super User
This imports the data but I see no attempt to analyze the data or questions. You can start with PROC FREQ and SUMMARY tutorials perhaps?

FREQ tutorial
https://www.lexjansen.com/nesug/nesug07/ff/ff07.pdf

MEANS tutorial
https://www.lexjansen.com/nesug/nesug08/ff/ff06.pdf
ballardw
Super User

Many users here don't want to download DOCX files because of virus potential, others have such things blocked by security software or organization policy. Also if you give us DOCX we have to create a SAS data set and due to the non-existent constraints the result we end up with may not have variables of the same type (numeric or character) and even values.

 

Data should be in form of a data step (good learning point right there). The show what you have attempted and describe why it didn't work.

 

Since you have a question involving time interval this also might be of use: https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/... has a PDF with much information about dates.

 

 

tarheel13
Rhodochrosite | Level 12

If it was me, I would make 2 new variables, day5 and day10. I would make them like this: day5 = exp_date + 5 and day10=exp_date + 10. Then you need to merge the datasets by person ID. Then you can make a boolean variable like this:

flag = day5 <= test_date <= day10. This will assign flag to 1 if the conditions are true and 0 if false. If the combined dataset is not 1 row per person, then you will need to collapse it down to 1 row per person. Once you have a person-level dataset, then you can do proc freq on the flag variable to get the proportion. 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 950 views
  • 2 likes
  • 4 in conversation